This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
readelf versus DW_AT_data_member_location
- From: Mark Wielaard <mjw at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Wed, 08 Jul 2009 19:31:11 +0200
- Subject: readelf versus DW_AT_data_member_location
Hi,
According to the Dwarf spec DW_AT_data_member_location can also take a
simple constant offset when encoded as DW_FORM_data[12] or
DW_FORM_[us]data. I submitted a patch to gcc to output that instead of a
whole location expression block when possible. The attached patch makes
readelf display such simple offsets as constants.
Cheers,
Mark
>From f735db16b52665f2324eff101f0e5cad861bfea2 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mjw@redhat.com>
Date: Wed, 8 Jul 2009 19:18:53 +0200
Subject: [PATCH] Handle DW_Form constants for DW_AT_data_member_location in readelf.
---
src/ChangeLog | 5 +++++
src/readelf.c | 13 ++++++++++++-
2 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index e274942..51b3dd8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2009-07-08 Mark Wielaard <mjw@redhat.com>
+
+ * readelf.c (attr_callback): Handle DW_Form constants for
+ DW_AT_data_member_location.
+
2009-07-06 Roland McGrath <roland@redhat.com>
* readelf.c (register_info): New function. Handle unknown register #s.
diff --git a/src/readelf.c b/src/readelf.c
index c8bb2f0..bc67c31 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -5135,9 +5135,20 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
const char *valuestr = NULL;
switch (attr)
{
+ /* 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)
+ {
+ printf (" %*s%-20s %" PRIxMAX "\n",
+ (int) (level * 2), "", dwarf_attr_string (attr),
+ (uintmax_t) num);
+ return DWARF_CB_OK;
+ }
+ /* else fallthrough */
+
+ /* These cases always take a loclistptr and no constant. */
case DW_AT_location:
case DW_AT_data_location:
- case DW_AT_data_member_location:
case DW_AT_vtable_elem_location:
case DW_AT_string_length:
case DW_AT_use_location:
--
1.6.2.5