summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2012-06-25 17:18:53 +0200
committerMark Wielaard <mjw@redhat.com>2012-06-27 10:02:59 +0200
commita0172d75311f36adb6db58000474d31f8a9cd553 (patch)
tree39bce79b9c203afcb2283f3d0994830999c912c2
parentb2589ffa7c2bec754952acc8116e03853d65563d (diff)
downloadelfutils-a0172d75311f36adb6db58000474d31f8a9cd553.tar.gz
Add low-level support for .debug_macro.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
-rw-r--r--libdw/ChangeLog7
-rw-r--r--libdw/dwarf.h1
-rw-r--r--libdw/dwarf_begin_elf.c1
-rw-r--r--libdw/dwarf_formudata.c10
-rw-r--r--libdw/libdwP.h1
-rw-r--r--libebl/ChangeLog4
-rw-r--r--libebl/eblopenbackend.c2
-rw-r--r--src/ChangeLog4
-rw-r--r--src/readelf.c4
-rw-r--r--tests/ChangeLog6
-rw-r--r--tests/Makefile.am6
-rwxr-xr-xtests/run-macro-test.sh53
-rwxr-xr-xtests/testfile-macinfo.bz2bin0 -> 6689 bytes
-rwxr-xr-xtests/testfile-macros.bz2bin0 -> 7882 bytes
14 files changed, 96 insertions, 3 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 3ff83e45..48bbaa0e 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,10 @@
+2012-06-26 Mark Wielaard <mjw@redhat.com>
+
+ * libdwP.h: Add IDX_debug_macro.
+ * dwarf.h: Add DW_AT_GNU_macros.
+ * dwarf_begin_elf.c (dwarf_scnnames): Add .debug_macro.
+ * dwarf_formudata.c (dwarf_formudata): Recognize DW_AT_GNU_macros.
+
2012-04-27 Mark Wielaard <mjw@redhat.com>
* libdw/dwarf_highpc.c (dwarf_highpc): Handle DW_AT_high_pc being
diff --git a/libdw/dwarf.h b/libdw/dwarf.h
index 38f663d6..01aee5ad 100644
--- a/libdw/dwarf.h
+++ b/libdw/dwarf.h
@@ -266,6 +266,7 @@ enum
DW_AT_GNU_all_tail_call_sites = 0x2116,
DW_AT_GNU_all_call_sites = 0x2117,
DW_AT_GNU_all_source_call_sites = 0x2118,
+ DW_AT_GNU_macros = 0x2119,
DW_AT_hi_user = 0x3fff
};
diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
index fc6ac8d6..3e01800a 100644
--- a/libdw/dwarf_begin_elf.c
+++ b/libdw/dwarf_begin_elf.c
@@ -61,6 +61,7 @@ static const char dwarf_scnnames[IDX_last][17] =
[IDX_debug_pubnames] = ".debug_pubnames",
[IDX_debug_str] = ".debug_str",
[IDX_debug_macinfo] = ".debug_macinfo",
+ [IDX_debug_macro] = ".debug_macro",
[IDX_debug_ranges] = ".debug_ranges"
};
#define ndwarf_scnnames (sizeof (dwarf_scnnames) / sizeof (dwarf_scnnames[0]))
diff --git a/libdw/dwarf_formudata.c b/libdw/dwarf_formudata.c
index f5b2a1a1..f08e0d8f 100644
--- a/libdw/dwarf_formudata.c
+++ b/libdw/dwarf_formudata.c
@@ -140,13 +140,21 @@ dwarf_formudata (attr, return_uval)
break;
case DW_AT_macro_info:
- /* macptr */
+ /* macptr into .debug_macinfo */
if (__libdw_formptr (attr, IDX_debug_macinfo,
DWARF_E_NO_ENTRY, NULL,
return_uval) == NULL)
return -1;
break;
+ case DW_AT_GNU_macros:
+ /* macptr into .debug_macro */
+ if (__libdw_formptr (attr, IDX_debug_macro,
+ DWARF_E_NO_ENTRY, NULL,
+ return_uval) == NULL)
+ return -1;
+ break;
+
case DW_AT_ranges:
case DW_AT_start_scope:
/* rangelistptr */
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index 3c1925b3..77e1b31f 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -71,6 +71,7 @@ enum
IDX_debug_pubnames,
IDX_debug_str,
IDX_debug_macinfo,
+ IDX_debug_macro,
IDX_debug_ranges,
IDX_last
};
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index ac2160de..941ed6f1 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,7 @@
+2011-06-26 Mark Wielaard <mjw@redhat.com>
+
+ * eblopenbackend.c (default_debugscn_p): Add .debug_macro.
+
2011-04-26 Mark Wielaard <mjw@redhat.com>
* libebl.h (ebl_object_note_type_name): Add const char *name arg.
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index 9789ef37..b39ab2e9 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -646,6 +646,8 @@ default_debugscn_p (const char *name)
".debug_types",
/* GDB DWARF 4 extension */
".gdb_index",
+ /* GNU/DWARF 5 extension/proposal */
+ ".debug_macro",
/* SGI/MIPS DWARF 2 extensions */
".debug_weaknames",
".debug_funcnames",
diff --git a/src/ChangeLog b/src/ChangeLog
index 40905b8a..2928ab1f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2012-06-26 Mark Wielaard <mjw@redhat.com>
+
+ * readelf.c (dwarf_attr_string): Add DW_AT_GNU_macros.
+
2012-06-22 Mark Wielaard <mjw@redhat.com>
* readelf.c (print_ops): Cast printf PRIu/x64 arguments to uint64_t
diff --git a/src/readelf.c b/src/readelf.c
index d182ab50..eb1d469d 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -3590,6 +3590,10 @@ dwarf_attr_string (unsigned int attrnum)
result = "GNU_all_source_call_sites";
break;
+ case DW_AT_GNU_macros:
+ result = "GNU_macros";
+ break;
+
default:
if (attrnum < DW_AT_lo_user)
snprintf (buf, sizeof buf, gettext ("unknown attribute %hx"),
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 6f5e4584..9b649173 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,9 @@
+2012-06-26 Mark Wielaard <mjw@redhat.com>
+
+ * run-macro-test.sh: New test.
+ * testfile-macinfo.bz2: New testfile.
+ * testfile-macros.bz2: Likewise.
+
2012-05-07 Mark Wielaard <mjw@redhat.com>
* low_high_pc.c: Use proper inttypes in printf formats.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ced7831b..39e58ae8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -79,7 +79,8 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
run-early-offscn.sh run-dwarf-getmacros.sh \
run-test-flag-nobits.sh run-prelink-addr-test.sh \
run-dwarf-getstring.sh run-rerequest_tag.sh run-typeiter.sh \
- run-readelf-d.sh run-unstrip-n.sh run-low_high_pc.sh
+ run-readelf-d.sh run-unstrip-n.sh run-low_high_pc.sh \
+ run-macro-test.sh
if !STANDALONE
noinst_PROGRAMS += msg_tst md5-sha1-test
@@ -157,7 +158,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
run-typeiter.sh testfile59.bz2 \
run-readelf-d.sh testlib_dynseg.so.bz2 \
run-unstrip-n.sh testcore-rtlib.bz2 \
- run-low_high_pc.sh testfile_low_high_pc.bz2
+ run-low_high_pc.sh testfile_low_high_pc.bz2 \
+ run-macro-test.sh testfile-macinfo.bz2 testfile-macros.bz2
installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir) \
bindir=$(DESTDIR)$(bindir) \
diff --git a/tests/run-macro-test.sh b/tests/run-macro-test.sh
new file mode 100755
index 00000000..70a16edf
--- /dev/null
+++ b/tests/run-macro-test.sh
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2012 Red Hat, Inc.
+# This file is part of elfutils.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# elfutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. $srcdir/test-subr.sh
+
+# #include <string.h>
+#
+# #define HELLO "world"
+#
+# int
+# main(int argc, char ** argv)
+# {
+# return strlen (HELLO);
+# }
+#
+# gcc -gdwarf-4 -g3 -o testfile-macros macro.c
+# gcc -gstrict-dwarf -gdwarf-4 -g3 -o testfile-macinfo macro.c
+
+testfiles testfile-macinfo testfile-macros
+
+status=0
+
+testrun ../src/readelf --debug-dump=info testfile-macinfo \
+ | grep macro_info > readelf.macros.out ||
+ { echo "*** failure readelf --debug-dump=info testfile-macinfo"; status=1; }
+testrun_compare cat readelf.macros.out <<\EOF
+ macro_info (sec_offset) 0
+EOF
+
+testrun ../src/readelf --debug-dump=info testfile-macros \
+ | grep GNU_macros > readelf.macros.out ||
+ { echo "*** failure readelf --debug-dump=info testfile-macros"; status=1; }
+testrun_compare cat readelf.macros.out <<\EOF
+ GNU_macros (sec_offset) 0
+EOF
+
+rm -f readelf.macros.out
+
+exit $status
diff --git a/tests/testfile-macinfo.bz2 b/tests/testfile-macinfo.bz2
new file mode 100755
index 00000000..e6cc5f1c
--- /dev/null
+++ b/tests/testfile-macinfo.bz2
Binary files differ
diff --git a/tests/testfile-macros.bz2 b/tests/testfile-macros.bz2
new file mode 100755
index 00000000..d74df94c
--- /dev/null
+++ b/tests/testfile-macros.bz2
Binary files differ