diff options
| author | Mark Wielaard <[email protected]> | 2018-05-08 15:34:03 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2018-05-11 17:27:00 +0200 |
| commit | af1438086468f936dfb041daed59a3367fe24a07 (patch) | |
| tree | 554faa8bbdfd721a9368a94ba377be223eca2a39 | |
| parent | 982b6fe9e31683607d476d7f90d1b56cbb78aa21 (diff) | |
libdw: Handle DW_FORM_[ref|strp]_sup[48] as DW_FORM_GNU_[ref|strp]_alt.
Although we don't yet handle DWARF5 supplemental files, they are like
mostly like GNU alt files. This way using any of the supplemental files
will at least generate an appropriate error message.
Signed-off-by: Mark Wielaard <[email protected]>
| -rw-r--r-- | libdw/ChangeLog | 9 | ||||
| -rw-r--r-- | libdw/dwarf_formref.c | 2 | ||||
| -rw-r--r-- | libdw/dwarf_formref_die.c | 15 | ||||
| -rw-r--r-- | libdw/dwarf_formstring.c | 6 | ||||
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/readelf.c | 2 |
6 files changed, 33 insertions, 6 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog index cc7eae9d..5e2c0d81 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,12 @@ +2018-05-08 Mark Wielaard <[email protected]> + + * dwarf_formref.c (__libdw_formref): Explicitly don't handle + DW_FORM_ref_sup4 and DW_FORM_ref_sup8. + * dwarf_formref_die.c (dwarf_formref_die): Handle DW_FORM_ref_sup4 + and DW_FORM_ref_sup8. + * dwarf_formstring.c (dwarf_formstring): Handle DW_FORM_strp_sup + as DW_FORM_GNU_strp_alt. + 2018-05-05 Mark Wielaard <[email protected]> * dwarf.h: Add DWARF line content descriptions. diff --git a/libdw/dwarf_formref.c b/libdw/dwarf_formref.c index 2240a258..2bae2a44 100644 --- a/libdw/dwarf_formref.c +++ b/libdw/dwarf_formref.c @@ -86,6 +86,8 @@ __libdw_formref (Dwarf_Attribute *attr, Dwarf_Off *return_offset) case DW_FORM_ref_addr: case DW_FORM_ref_sig8: case DW_FORM_GNU_ref_alt: + case DW_FORM_ref_sup4: + case DW_FORM_ref_sup8: /* These aren't handled by dwarf_formref, only by dwarf_formref_die. */ __libdw_seterrno (DWARF_E_INVALID_REFERENCE); return -1; diff --git a/libdw/dwarf_formref_die.c b/libdw/dwarf_formref_die.c index d47fb2f5..f196331a 100644 --- a/libdw/dwarf_formref_die.c +++ b/libdw/dwarf_formref_die.c @@ -44,13 +44,20 @@ dwarf_formref_die (Dwarf_Attribute *attr, Dwarf_Die *result) struct Dwarf_CU *cu = attr->cu; Dwarf_Off offset; - if (attr->form == DW_FORM_ref_addr || attr->form == DW_FORM_GNU_ref_alt) + if (attr->form == DW_FORM_ref_addr || attr->form == DW_FORM_GNU_ref_alt + || attr->form == DW_FORM_ref_sup4 || attr->form == DW_FORM_ref_sup8) { /* This has an absolute offset. */ - uint8_t ref_size = (cu->version == 2 && attr->form == DW_FORM_ref_addr - ? cu->address_size - : cu->offset_size); + uint8_t ref_size; + if (cu->version == 2 && attr->form == DW_FORM_ref_addr) + ref_size = cu->address_size; + else if (attr->form == DW_FORM_ref_sup4) + ref_size = 4; + else if (attr->form == DW_FORM_ref_sup8) + ref_size = 8; + else + ref_size = cu->offset_size; Dwarf *dbg_ret = (attr->form == DW_FORM_GNU_ref_alt ? INTUSE(dwarf_getalt) (cu->dbg) : cu->dbg); diff --git a/libdw/dwarf_formstring.c b/libdw/dwarf_formstring.c index e7396a79..c55c7f04 100644 --- a/libdw/dwarf_formstring.c +++ b/libdw/dwarf_formstring.c @@ -48,7 +48,8 @@ dwarf_formstring (Dwarf_Attribute *attrp) Dwarf_CU *cu = attrp->cu; Dwarf *dbg = cu->dbg; - Dwarf *dbg_ret = (attrp->form == DW_FORM_GNU_strp_alt + Dwarf *dbg_ret = ((attrp->form == DW_FORM_GNU_strp_alt + || attrp->form == DW_FORM_strp_sup) ? INTUSE(dwarf_getalt) (dbg) : dbg); if (unlikely (dbg_ret == NULL)) @@ -70,7 +71,8 @@ dwarf_formstring (Dwarf_Attribute *attrp) uint64_t off; if (attrp->form == DW_FORM_strp - || attrp->form == DW_FORM_GNU_strp_alt) + || attrp->form == DW_FORM_GNU_strp_alt + || attrp->form == DW_FORM_strp_sup) { if (__libdw_read_offset (dbg, dbg_ret, cu_sec_idx (cu), attrp->valp, cu->offset_size, &off, diff --git a/src/ChangeLog b/src/ChangeLog index 4b55bbcd..b1041a83 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2018-05-05 Mark Wielaard <[email protected]> + + * readelf.c (attr_callback): Handle DW_FORM_ref_sup4 and + DW_FORM_ref_sup8 as references. + 2018-04-24 Mark Wielaard <[email protected]> * readelf.c (print_debug_str_section): Take raw section data. Don't diff --git a/src/readelf.c b/src/readelf.c index c2fcfff9..c69910ab 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -6130,6 +6130,8 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) case DW_FORM_ref2: case DW_FORM_ref1: case DW_FORM_GNU_ref_alt: + case DW_FORM_ref_sup4: + case DW_FORM_ref_sup8: if (cbargs->silent) break; Dwarf_Die ref; |
