From 7fac1ce75275f8b48ce2ede108c1a645bf77f7cc Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 1 Jun 2010 15:56:58 -0700 Subject: [PATCH] More DWARF 4 handling, some in readelf. --- NEWS | 2 ++ libdw/ChangeLog | 2 ++ libdw/dwarf_formblock.c | 3 ++- src/ChangeLog | 4 ++++ src/readelf.c | 32 ++++++++++++++++++++++++++------ 5 files changed, 36 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index de1740f..fe14138 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,8 @@ libdw: Accept DWARF 4 format. libdwfl: Fixes in core-file handling, support cores from PIEs. When working from build IDs, don't open a named file that mismatches. +readelf: Handle some DWARF 4 format bits. + Version 0.147: libdw: Fixes in CFI handling, best possible handling of bogus CFA ops. diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 156ba80..6712abf 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,5 +1,7 @@ 2010-06-01 Roland McGrath + * dwarf_formblock.c (dwarf_formblock): Handle DW_FORM_exprloc. + * libdw_findcu.c (__libdw_findcu): Accept version 4. 2010-05-31 Mark Wielaard diff --git a/libdw/dwarf_formblock.c b/libdw/dwarf_formblock.c index 51396d4..6d7b9d3 100644 --- a/libdw/dwarf_formblock.c +++ b/libdw/dwarf_formblock.c @@ -1,5 +1,5 @@ /* Return block represented by attribute. - Copyright (C) 2004, 2005 Red Hat, Inc. + Copyright (C) 2004-2010 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Ulrich Drepper , 2004. @@ -84,6 +84,7 @@ dwarf_formblock (attr, return_block) break; case DW_FORM_block: + case DW_FORM_exprloc: datap = attr->valp; get_uleb128 (return_block->length, datap); return_block->data = (unsigned char *) datap; diff --git a/src/ChangeLog b/src/ChangeLog index 4a6389a..f3dcb52 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2010-06-01 Roland McGrath + * readelf.c (dwarf_form_string): Handle DWARF 4 forms. + (attr_callback): Handle DW_FORM_flag_present, DW_FORM_exprloc, + DW_FORM_sec_offset. + * readelf.c (print_debug): Don't bail if libdw setup fails. Suppress complaint if we only want .eh_frame anyway. diff --git a/src/readelf.c b/src/readelf.c index 0d8c431..578bf10 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -3515,7 +3515,11 @@ dwarf_form_string (unsigned int form) [DW_FORM_ref4] = "ref4", [DW_FORM_ref8] = "ref8", [DW_FORM_ref_udata] = "ref_udata", - [DW_FORM_indirect] = "indirect" + [DW_FORM_indirect] = "indirect", + [DW_FORM_sec_offset] = "sec_offset", + [DW_FORM_exprloc] = "exprloc", + [DW_FORM_flag_present] = "flag_present", + [DW_FORM_ref_sig8] = "ref_sig8" }; const unsigned int nknown_forms = (sizeof (known_forms) / sizeof (known_forms[0])); @@ -5184,6 +5188,10 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) dwarf_form_string (form), (uintmax_t) dwarf_dieoffset (&ref)); break; + case DW_FORM_sec_offset: + attrp->form = cbargs->offset_size == 8 ? DW_FORM_data8 : DW_FORM_data4; + /* Fall through. */ + case DW_FORM_udata: case DW_FORM_sdata: case DW_FORM_data8: @@ -5199,7 +5207,8 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) { /* This case can take either a constant or a loclistptr. */ case DW_AT_data_member_location: - if (form != DW_FORM_data4 && form != DW_FORM_data8) + if (form != DW_FORM_data4 && form != DW_FORM_data8 + && form != DW_FORM_sec_offset) /* XXX not data[48] if CU v4! */ { printf (" %*s%-20s (%s) %" PRIxMAX "\n", (int) (level * 2), "", dwarf_attr_string (attr), @@ -5283,6 +5292,13 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) dwarf_form_string (form), nl_langinfo (flag ? YESSTR : NOSTR)); break; + case DW_FORM_flag_present: + printf (" %*s%-20s (%s) %s\n", + (int) (level * 2), "", dwarf_attr_string (attr), + dwarf_form_string (form), nl_langinfo (YESSTR)); + break; + + case DW_FORM_exprloc: case DW_FORM_block4: case DW_FORM_block2: case DW_FORM_block1: @@ -5297,6 +5313,14 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) switch (attr) { + default: + if (form != DW_FORM_exprloc) + { + print_block (block.length, block.data); + break; + } + /* Fall through. */ + case DW_AT_location: case DW_AT_data_location: case DW_AT_data_member_location: @@ -5321,10 +5345,6 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) cbargs->addrsize, cbargs->offset_size, block.length, block.data); break; - - default: - print_block (block.length, block.data); - break; } break; -- 2.7.4