libdw: Add explicit section index to struct Dwarf_CU.

The DIE (attribute) data might come from either the main .debug_info
section or for DWARFv4 from a separate .debug_types section. Or in
case of the fake_loc_cu from the .debug_loc section and in the case
of macros from the .debug_macinfo or .debug_macro section.

We didn't handle the last two "fake" CU cases correctly when sanity
checking offsets in __libdw_read_address and __libdw_read_offset.

Add an explicit sec_idx field to struct Dwarf_CU that is always set
to the actual section that the data came from.

Signed-off-by: Mark Wielaard <mark@klomp.org>
5 files changed