Dwarf_Adrr and Dwarf_Off are 64-bit unsigned, and comparison functions
used in qsort or tfind return int, it is possible for the difference to
be so large that it wraps around. Make sure to just return -1, 0 or 1
in compare_aranges and compare_cukey.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
+2014-12-13 Mark Wielaard <mjw@redhat.com>
+
+ * dwarf_getaranges.c (compare_aranges): Make sure Dwarf_Addr
+ difference doesn't wrap around before returning as int.
+
2014-12-11 Josh Stone <jistone@redhat.com>
* dwarf_getsrclines.c (struct linelist): Add sequence.
{
struct arangelist *const *p1 = a, *const *p2 = b;
struct arangelist *l1 = *p1, *l2 = *p2;
- return l1->arange.addr - l2->arange.addr;
+ if (l1->arange.addr != l2->arange.addr)
+ return (l1->arange.addr < l2->arange.addr) ? -1 : 1;
+ return 0;
}
int
+2014-12-13 Mark Wielaard <mjw@redhat.com>
+
+ * cu.c (cudie_offset): Make sure Dwarf_Off difference doesn't
+ wrap around before returning as int.
+
2014-12-11 Josh Stone <jistone@redhat.com>
* dwfl_module_getsrc.c (dwfl_module_getsrc): Return the *last* line
static int
compare_cukey (const void *a, const void *b)
{
- return cudie_offset (a) - cudie_offset (b);
+ Dwarf_Off a_off = cudie_offset (a);
+ Dwarf_Off b_off = cudie_offset (b);
+ return (a_off < b_off) ? -1 : ((a_off > b_off) ? 1 : 0);
}
/* Intern the CU if necessary. */