summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2018-10-13 15:08:16 +0200
committerMark Wielaard <[email protected]>2018-10-19 23:57:22 +0200
commit2f4a040fab520a97480f6ca6fa9fcef88bc55255 (patch)
tree951251cfa89f26d477f973dbc6af9db36b10594d /src
parenteee4269e53154daaf0251371aacd91ec5db3eb30 (diff)
readelf: Handle multiple .debug_macro sections and decode header flag.
In object files there could be multiple .debug_macro sections. These are COMDAT sections used as imports. Note that the output for DW_MACRO_import isn't ideal since the offset is printed against the start of the .debug_macro section, but it doesn't show which one. We currently don't have that information and no interface yet for libdw users. Also decode the macro header flag byte for convenience. Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/readelf.c31
2 files changed, 34 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 5aa31fc7..680291be 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2018-09-13 Mark Wielaard <[email protected]>
+
+ * readelf.c (print_debug_macro_section): Use elf_getdata. Print
+ decoded flag string.
+2018-09-13 Mark Wielaard <[email protected]>
+
2018-10-19 Mark Wielaard <[email protected]>
* unstrip.c (copy_elided_sections): Renumber group section indexes.
diff --git a/src/readelf.c b/src/readelf.c
index bddcd703..366e2c3d 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -9702,8 +9702,7 @@ print_debug_macro_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
(uint64_t) shdr->sh_offset);
putc_unlocked ('\n', stdout);
- Elf_Data *data = (dbg->sectiondata[IDX_debug_macro]
- ?: elf_rawdata (scn, NULL));
+ Elf_Data *data = elf_getdata (scn, NULL);
if (unlikely (data == NULL))
{
error (0, 0, gettext ("cannot get macro information section data: %s"),
@@ -9772,7 +9771,33 @@ print_debug_macro_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
if (readp + 1 > readendp)
goto invalid_data;
const unsigned char flag = *readp++;
- printf (gettext (" Flag: 0x%" PRIx8 "\n"), flag);
+ printf (gettext (" Flag: 0x%" PRIx8), flag);
+ if (flag != 0)
+ {
+ printf (" (");
+ if ((flag & 0x01) != 0)
+ {
+ printf ("offset_size");
+ if ((flag & 0xFE) != 0)
+ printf (", ");
+ }
+ if ((flag & 0x02) != 0)
+ {
+ printf ("debug_line_offset");
+ if ((flag & 0xFC) != 0)
+ printf (", ");
+ }
+ if ((flag & 0x04) != 0)
+ {
+ printf ("operands_table");
+ if ((flag & 0xF8) != 0)
+ printf (", ");
+ }
+ if ((flag & 0xF8) != 0)
+ printf ("unknown");
+ printf (")");
+ }
+ printf ("\n");
unsigned int offset_len = (flag & 0x01) ? 8 : 4;
printf (gettext (" Offset length: %" PRIu8 "\n"), offset_len);