summaryrefslogtreecommitdiffstats
path: root/libdw/libdw_findcu.c
diff options
context:
space:
mode:
authorUlf Hermann <[email protected]>2017-12-21 14:30:36 +0100
committerUlf Hermann <[email protected]>2017-12-21 14:03:12 +0000
commite556d22e3f6f59301c5a2616507c1a2357b01798 (patch)
tree944528e11552e89f521226407618c47be2f9f3a6 /libdw/libdw_findcu.c
parentbc26cd7ca3a60aaaeed86b1dfd69d31287ee26d3 (diff)
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. Change-Id: I83260622b55d3778a38cd46427dba158d186c51e Reviewed-by: Christian Kandeler <[email protected]>
Diffstat (limited to 'libdw/libdw_findcu.c')
-rw-r--r--libdw/libdw_findcu.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libdw/libdw_findcu.c b/libdw/libdw_findcu.c
index 082307b0..4e025e26 100644
--- a/libdw/libdw_findcu.c
+++ b/libdw/libdw_findcu.c
@@ -93,8 +93,8 @@ __libdw_intern_next_unit (Dwarf *dbg, bool debug_types)
}
/* Invalid or truncated debug section data? */
- Elf_Data *data = dbg->sectiondata[debug_types
- ? IDX_debug_types : IDX_debug_info];
+ size_t sec_idx = debug_types ? IDX_debug_types : IDX_debug_info;
+ Elf_Data *data = dbg->sectiondata[sec_idx];
if (unlikely (*offsetp > data->d_size))
*offsetp = data->d_size;
@@ -102,6 +102,7 @@ __libdw_intern_next_unit (Dwarf *dbg, bool debug_types)
struct Dwarf_CU *newp = libdw_typed_alloc (dbg, struct Dwarf_CU);
newp->dbg = dbg;
+ newp->sec_idx = sec_idx;
newp->start = oldoff;
newp->end = *offsetp;
newp->address_size = address_size;