Skip to content

Commit b720233

Browse files
Anders Grahnangrq
authored andcommitted
libply: Fix kallsym lookup for split 64bit address space
Fixup the kallsym sort-compare function. Sorting the kallsyms breaks when comparing addresses that are more than INT_MAX bytes apart. The could break e.g. the stack or caller output. Seen on a ppc64 Linux kernel where kernel memory is divided into different address regions. Kernel modules are placed at 0xc0000100xxxxxxx and the core kernel at 0xc000000xxxxxxx. Signed-off-by: Anders Grahn <anders.grahn@westermo.com>
1 parent a9b778e commit b720233

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/libply/aux/kallsyms.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,12 @@ static int ksym_sort_cmp(const void *_a, const void *_b)
223223
{
224224
const struct ksym *a = _a, *b = _b;
225225

226-
return a->addr - b->addr;
226+
if (a->addr > b->addr)
227+
return 1;
228+
else if (a->addr < b->addr)
229+
return -1;
230+
else
231+
return 0;
227232
}
228233

229234
static int ksyms_cache_sort(struct ksyms *ks)

0 commit comments

Comments
 (0)