diff options
| author | Mark Wielaard <[email protected]> | 2014-04-09 22:38:07 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2014-04-15 14:19:55 +0200 |
| commit | f7cdc74ed34adc539186385342d99b357c3dbb6b (patch) | |
| tree | fd1e9457baa0c261a87cae57f5d2c22f25a15b86 /src | |
| parent | 110c273d35515ebcfba0c88ad70dbcd5548b0d3c (diff) | |
readelf: Read the decompressed data when processing .zdebug DWARF sections.
readelf uses libdw to open the Dwarf and read some of the DWARF data.
But it also uses its own parsers to display some of the low-level
unprocessed data. If the DWARF debug section was zlib compressed it
should actually use the decompressed section data from libdw instead
of the raw section data.
Includes a testcase for those sections that couldn't be properly
displayed when compressed before.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/readelf.c | 18 |
2 files changed, 21 insertions, 8 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index a6218e23..2844daf6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2014-04-09 Mark Wielaard <[email protected]> + + * readelf.c (print_debug_aranges_section): Don't get the raw section + data, use the possibly decompressed .[z]debug sectiondata. + (print_debug_ranges_section): Likewise. + (print_debug_frame_section): Likewise. + (print_debug_line_section): Likewise. + (print_debug_loc_section): Likewise. + (print_debug_macinfo_section): Likewise. + (print_debug_macro_section): Likewise. + 2014-04-10 Mark Wielaard <[email protected]> * readelf.c (buf_read_ulong): Pass actual long size to convert. diff --git a/src/readelf.c b/src/readelf.c index ff8048ef..8a9543dc 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -4516,7 +4516,7 @@ print_debug_aranges_section (Dwfl_Module *dwflmod __attribute__ ((unused)), return; } - Elf_Data *data = elf_rawdata (scn, NULL); + Elf_Data *data = dbg->sectiondata[IDX_debug_aranges]; if (unlikely (data == NULL)) { @@ -4670,7 +4670,7 @@ print_debug_ranges_section (Dwfl_Module *dwflmod, Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg) { - Elf_Data *data = elf_rawdata (scn, NULL); + Elf_Data *data = dbg->sectiondata[IDX_debug_ranges]; if (unlikely (data == NULL)) { @@ -5183,7 +5183,10 @@ print_debug_frame_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, return; } - Elf_Data *data = elf_rawdata (scn, NULL); + bool is_eh_frame = strcmp (scnname, ".eh_frame") == 0; + Elf_Data *data = (is_eh_frame + ? elf_rawdata (scn, NULL) + : dbg->sectiondata[IDX_debug_frame]); if (unlikely (data == NULL)) { @@ -5191,7 +5194,6 @@ print_debug_frame_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, scnname, elf_errmsg (-1)); return; } - bool is_eh_frame = strcmp (scnname, ".eh_frame") == 0; if (is_eh_frame) printf (gettext ("\ @@ -6122,7 +6124,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, /* There is no functionality in libdw to read the information in the way it is represented here. Hardcode the decoder. */ - Elf_Data *data = elf_getdata (scn, NULL); + Elf_Data *data = dbg->sectiondata[IDX_debug_line]; if (unlikely (data == NULL || data->d_buf == NULL)) { error (0, 0, gettext ("cannot get line data section data: %s"), @@ -6604,7 +6606,7 @@ print_debug_loc_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg) { - Elf_Data *data = elf_rawdata (scn, NULL); + Elf_Data *data = dbg->sectiondata[IDX_debug_loc]; if (unlikely (data == NULL)) { @@ -6741,7 +6743,7 @@ print_debug_macinfo_section (Dwfl_Module *dwflmod __attribute__ ((unused)), /* There is no function in libdw to iterate over the raw content of the section but it is easy enough to do. */ - Elf_Data *data = elf_getdata (scn, NULL); + Elf_Data *data = dbg->sectiondata[IDX_debug_macinfo]; if (unlikely (data == NULL || data->d_buf == NULL)) { error (0, 0, gettext ("cannot get macro information section data: %s"), @@ -6895,7 +6897,7 @@ print_debug_macro_section (Dwfl_Module *dwflmod __attribute__ ((unused)), (uint64_t) shdr->sh_offset); putc_unlocked ('\n', stdout); - Elf_Data *data = elf_getdata (scn, NULL); + Elf_Data *data = dbg->sectiondata[IDX_debug_macro]; if (unlikely (data == NULL || data->d_buf == NULL)) { error (0, 0, gettext ("cannot get macro information section data: %s"), |
