]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Add low-level support for .debug_macro.
authorMark Wielaard <mjw@redhat.com>
Mon, 25 Jun 2012 15:18:53 +0000 (17:18 +0200)
committerMark Wielaard <mjw@redhat.com>
Wed, 27 Jun 2012 08:02:59 +0000 (10:02 +0200)
Signed-off-by: Mark Wielaard <mjw@redhat.com>
14 files changed:
libdw/ChangeLog
libdw/dwarf.h
libdw/dwarf_begin_elf.c
libdw/dwarf_formudata.c
libdw/libdwP.h
libebl/ChangeLog
libebl/eblopenbackend.c
src/ChangeLog
src/readelf.c
tests/ChangeLog
tests/Makefile.am
tests/run-macro-test.sh [new file with mode: 0755]
tests/testfile-macinfo.bz2 [new file with mode: 0755]
tests/testfile-macros.bz2 [new file with mode: 0755]

index 3ff83e45368938ae639aeb25159bb1569db1b369..48bbaa0e50ab66fba6bba07a8ae556f3a08ca74d 100644 (file)
@@ -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
index 38f663d6626183fae972e4efd1b784a83bdb0de3..01aee5ad752ba01ef8f1b6e55711e602a428bf96 100644 (file)
@@ -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
   };
index fc6ac8d6571397003b439e99356452a4e5b0a4d6..3e01800a545baa8ac37bbd6c38f73f739159cf47 100644 (file)
@@ -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]))
index f5b2a1a15f97f40f4576da7658486bcdde92dacc..f08e0d8f57c3ea023c186428992818023a058a56 100644 (file)
@@ -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 */
index 3c1925b3cb87cc1b1826fad085610431e925b62f..77e1b31f849704876cd71ff7d837204c93605ded 100644 (file)
@@ -71,6 +71,7 @@ enum
     IDX_debug_pubnames,
     IDX_debug_str,
     IDX_debug_macinfo,
+    IDX_debug_macro,
     IDX_debug_ranges,
     IDX_last
   };
index ac2160de95ff6ef8b9f57f65b50fdffd96362334..941ed6f1f8fba2ef1ecc1f43fb2d4147ec7e9f4c 100644 (file)
@@ -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.
index 9789ef37321b19a32e9bbd143af1fff0d65106cd..b39ab2e93d680b062863e8f452188ccb8c7e7743 100644 (file)
@@ -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",
index 40905b8a3f0c436b9bb8c6eedccac2ab328e4343..2928ab1f94ffb2e484ff994aaf3c0d5e6ccd79d1 100644 (file)
@@ -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
index d182ab50bdb318468a361e94c647c1af13d617ef..eb1d469d015685c5a35e8002ce5156e619a210d7 100644 (file)
@@ -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"),
index 6f5e458420a7cdb9306cccc88859335109a4c6bf..9b649173e99aebdce323af30dae770b6c6905379 100644 (file)
@@ -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.
index ced7831bbd68309c10426935e30453c9c4141b8a..39e58ae8679bfb08fa9d60b9e264dcd6eb6bb2f6 100644 (file)
@@ -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 (executable)
index 0000000..70a16ed
--- /dev/null
@@ -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 (executable)
index 0000000..e6cc5f1
Binary files /dev/null and b/tests/testfile-macinfo.bz2 differ
diff --git a/tests/testfile-macros.bz2 b/tests/testfile-macros.bz2
new file mode 100755 (executable)
index 0000000..d74df94
Binary files /dev/null and b/tests/testfile-macros.bz2 differ