gcc -fsanitize=undefined pointed out that on 32bit systems the calculation
to match the cie_offset to the cie_id could be undefined because a cie_id
could be an unsigned 64bit value while ptrdiff_t is only 32bits. Correct
the calculation to use 64bit values.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
+2015-03-22 Mark Wielaard <mjw@redhat.com>
+
+ * readelf.c (print_debug_frame_section): Cast start to Dwarf_Off
+ before subtracting cie_id. And cast cie_offset to Dwarf_Off before
+ comparison.
+
2015-03-22 Mark Wielaard <mjw@redhat.com>
* readelf.c (print_gdb_index_section): Check all offsets used
struct cieinfo *cie = cies;
while (cie != NULL)
if (is_eh_frame
- ? start - (ptrdiff_t) cie_id == cie->cie_offset
- : (ptrdiff_t) cie_id == cie->cie_offset)
+ ? ((Dwarf_Off) start - cie_id) == (Dwarf_Off) cie->cie_offset
+ : cie_id == (Dwarf_Off) cie->cie_offset)
break;
else
cie = cie->next;