+2017-12-20 Mark Wielaard <mark@klomp.org>
+
+ * libdwP.h (struct Dwarf_CU): Add sec_idx field.
+ (cu_sec_idx): Return cu->sec_idx.
+ * libdw_findcu.c (__libdw_intern_next_unit): Set cu sec_idx to
+ IDX_debug_info or IDX_debug_types.
+ * dwarf_begin_elf.c (valid_p): Set fake_loc_cu->sec_idx to
+ IDX_debug_loc.
+ * dwarf_getmacros.c (read_macros): Set fake_cu->sec_idx to
+ IDX_debug_macro or IDX_debug_macinfo.
+
2017-12-12 Mark Wielaard <mark@klomp.org>
* dwarf_aggregate_size.c (dwarf_aggregate_size): Don't peel the
}
else
{
+ result->fake_loc_cu->sec_idx = IDX_debug_loc;
result->fake_loc_cu->dbg = result;
result->fake_loc_cu->startp
= result->sectiondata[IDX_debug_loc]->d_buf;
Version 4 for the old GNU extension, version 5 for DWARF5. */
Dwarf_CU fake_cu = {
.dbg = dbg,
+ .sec_idx = sec_index,
.version = table->version,
.offset_size = table->is_64bit ? 8 : 4,
.startp = (void *) startp + offset,
uint8_t offset_size;
uint16_t version;
+ size_t sec_idx; /* Normally .debug_info, could be .debug_type or "fake". */
+
/* Zero if this is a normal CU. Nonzero if it is a type unit. */
size_t type_offset;
uint64_t type_sig8;
static inline size_t
cu_sec_idx (struct Dwarf_CU *cu)
{
- return cu->type_offset == 0 ? IDX_debug_info : IDX_debug_types;
+ return cu->sec_idx;
}
static inline bool
}
/* 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;
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;