diff options
Diffstat (limited to 'libdw/dwarf_getmacros.c')
-rw-r--r-- | libdw/dwarf_getmacros.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/libdw/dwarf_getmacros.c b/libdw/dwarf_getmacros.c index fd929669..a3a78884 100644 --- a/libdw/dwarf_getmacros.c +++ b/libdw/dwarf_getmacros.c @@ -124,17 +124,24 @@ get_macinfo_table (Dwarf *dbg, Dwarf_Word macoff, Dwarf_Die *cudie) = INTUSE(dwarf_attr) (cudie, DW_AT_stmt_list, &attr_mem); Dwarf_Off line_offset = (Dwarf_Off) -1; if (attr != NULL) - if (unlikely (INTUSE(dwarf_formudata) (attr, &line_offset) != 0)) - return NULL; + { + if (unlikely (INTUSE(dwarf_formudata) (attr, &line_offset) != 0)) + return NULL; + } + else if (cudie->cu->unit_type == DW_UT_split_compile + && dbg->sectiondata[IDX_debug_line] != NULL) + line_offset = 0; Dwarf_Macro_Op_Table *table = libdw_alloc (dbg, Dwarf_Macro_Op_Table, macinfo_data_size, 1); memcpy (table, macinfo_data, macinfo_data_size); + table->dbg = dbg; table->offset = macoff; table->sec_index = IDX_debug_macinfo; table->line_offset = line_offset; - table->is_64bit = cudie->cu->address_size == 8; + table->address_size = cudie->cu->address_size; + table->offset_size = cudie->cu->offset_size; table->comp_dir = __libdw_getcompdir (cudie); return table; @@ -182,6 +189,15 @@ get_table_for_offset (Dwarf *dbg, Dwarf_Word macoff, return NULL; } + uint8_t address_size; + if (cudie != NULL) + address_size = cudie->cu->address_size; + else + { + char *ident = elf_getident (dbg->elf, NULL); + address_size = ident[EI_CLASS] == ELFCLASS32 ? 4 : 8; + } + /* """The macinfo entry types defined in this standard may, but might not, be described in the table""". @@ -253,12 +269,14 @@ get_table_for_offset (Dwarf *dbg, Dwarf_Word macoff, macop_table_size, 1); *table = (Dwarf_Macro_Op_Table) { + .dbg = dbg, .offset = macoff, .sec_index = IDX_debug_macro, .line_offset = line_offset, .header_len = readp - startp, .version = version, - .is_64bit = is_64bit, + .address_size = address_size, + .offset_size = is_64bit ? 8 : 4, /* NULL if CUDIE is NULL or DW_AT_comp_dir is absent. */ .comp_dir = __libdw_getcompdir (cudie), @@ -368,7 +386,7 @@ read_macros (Dwarf *dbg, int sec_index, .dbg = dbg, .sec_idx = sec_index, .version = table->version, - .offset_size = table->is_64bit ? 8 : 4, + .offset_size = table->offset_size, .str_off_base = str_offsets_base_off (dbg, (cudie != NULL ? cudie->cu: NULL)), .startp = (void *) startp + offset, |