From f5519fc244d95dc04b3e3de88644d149a36a76b6 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 24 Aug 2012 13:54:52 +0200 Subject: [PATCH] Don't include dwz support by default. By default the dwz multi file support is not included. This means any DW_FORM_GNU_ref_alt or DW_FORM_GNU_strp_alt encountered in libdw will just produce an error message. A new configure option --enable-dwz is needed to include it for those we wish to test it. The dwz test is also disabled by default. Signed-off-by: Mark Wielaard --- ChangeLog | 4 ++++ NEWS | 4 +++- configure.ac | 8 ++++++++ libdw/ChangeLog | 7 +++++++ libdw/dwarf_begin_elf.c | 5 ++++- libdw/libdwP.h | 3 ++- tests/ChangeLog | 5 +++++ tests/Makefile.am | 6 +++++- 8 files changed, 38 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5842492..89fea8f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2012-08-24 Mark Wielaard + + * configure.ac: Add --enable-dwz check, defaults to no. + 2012-07-24 Mark Wielaard * TODO: Add note on shdrs after elf_cntl (ELF_C_FDREAD). diff --git a/NEWS b/NEWS index 610253d..c92f55c 100644 --- a/NEWS +++ b/NEWS @@ -9,7 +9,9 @@ libdw: dwarf.h corrected the DW_LANG_ObjC constant name (was DW_LANG_Objc). Any existing sources using the old name will have to be updated. Add DW_MACRO_GNU .debug_macro type encodings constants, DW_ATE_UTF and DW_OP_GNU_parameter_ref to dwarf.h. - Support for DWZ multifile forms DW_FORM_GNU_ref_alt/strp_alt. + Experimental support for DWZ multifile forms DW_FORM_GNU_ref_alt + and DW_FORM_GNU_strp_alt. Disabled by default. Use configure + --enable-dwz to test it. readelf: Add .debug_macro parsing support. Add .gdb_index version 7 parsing support. diff --git a/configure.ac b/configure.ac index 7932489..dbd3efc 100644 --- a/configure.ac +++ b/configure.ac @@ -67,6 +67,14 @@ AS_IF([test "$use_locks" = yes], [AC_DEFINE(USE_LOCKS)]) AH_TEMPLATE([USE_LOCKS], [Defined if libraries should be thread-safe.]) +AC_ARG_ENABLE([dwz], +AS_HELP_STRING([--enable-dwz], [enable experimental GNU ref_alt FORM, dwz multi file support in libdw]), +enable_dwz=$enableval, enable_dwz=no) +AM_CONDITIONAL(ENABLE_DWZ, test "$enable_dwz" = yes) +AS_IF([test "$enable_dwz" = yes], [AC_DEFINE(ENABLE_DWZ)]) + +AH_TEMPLATE([ENABLE_DWZ], [Defined if libdw should support GNU ref_alt FORM, dwz multi files.]) + AC_PROG_CC AC_PROG_RANLIB AC_PROG_YACC diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 89009f0..416a16f 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,10 @@ +2012-08-24 Mark Wielaard + + * dwarf_begin_elf.c (check_section): Only probe for dwz multi files + when ENABLE_DWZ is defined. + * libdwP.h (__check_build_id): Only declare when ENABLE_DWZ is + defined. + 2012-08-16 Mark Wielaard * Makefile.am (EXTRA_DIST): Add known-dwarf.h. diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c index fd95770..a9c826c 100644 --- a/libdw/dwarf_begin_elf.c +++ b/libdw/dwarf_begin_elf.c @@ -71,6 +71,7 @@ static const char dwarf_scnnames[IDX_last][17] = }; #define ndwarf_scnnames (sizeof (dwarf_scnnames) / sizeof (dwarf_scnnames[0])) +#ifdef ENABLE_DWZ internal_function int __check_build_id (Dwarf *dw, const uint8_t *build_id, const size_t id_len) { @@ -175,6 +176,7 @@ open_debugaltlink (Dwarf *result, const char *alt_name, result->alt_dwarf = NULL; return result; } +#endif /* ENABLE_DWZ */ static Dwarf * check_section (Dwarf *result, GElf_Ehdr *ehdr, Elf_Scn *scn, bool inscngrp) @@ -219,6 +221,7 @@ check_section (Dwarf *result, GElf_Ehdr *ehdr, Elf_Scn *scn, bool inscngrp) return NULL; } +#ifdef ENABLE_DWZ /* For dwz multifile support, ignore if it looks wrong. */ if (strcmp (scnname, ".gnu_debugaltlink") == 0) { @@ -232,7 +235,7 @@ check_section (Dwarf *result, GElf_Ehdr *ehdr, Elf_Scn *scn, bool inscngrp) return open_debugaltlink (result, alt_name, build_id + 1, id_len); } } - +#endif /* ENABLE_DWZ */ /* Recognize the various sections. Most names start with .debug_. */ size_t cnt; diff --git a/libdw/libdwP.h b/libdw/libdwP.h index da82e5d..76bddff 100644 --- a/libdw/libdwP.h +++ b/libdw/libdwP.h @@ -624,12 +624,13 @@ unsigned char * __libdw_formptr (Dwarf_Attribute *attr, int sec_index, Dwarf_Off *offsetp) internal_function; +#ifdef ENABLE_DWZ /* Checks that the build_id of the underlying Elf matches the expected. Returns zero on match, -1 on error or no build_id found or 1 when build_id doesn't match. */ int __check_build_id (Dwarf *dw, const uint8_t *build_id, const size_t id_len) internal_function; - +#endif /* ENABLE_DWZ */ /* Aliases to avoid PLTs. */ diff --git a/tests/ChangeLog b/tests/ChangeLog index f0c83e6..825b98a 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +2012-08-24 Mark Wielaard + + * Makefile.am (TESTS): Only add run-readelf-dwz-multi.sh if + ENABLE_DWZ. + 2012-08-16 Mark Wielaard * allregs.c (dwarf_encoding_string): Rewritten using known-dwarf diff --git a/tests/Makefile.am b/tests/Makefile.am index df66db6..724d866 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -73,7 +73,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \ run-nm-self.sh run-readelf-self.sh \ run-readelf-test1.sh run-readelf-test2.sh run-readelf-test3.sh \ run-readelf-test4.sh run-readelf-twofiles.sh \ - run-readelf-macro.sh run-readelf-dwz-multi.sh \ + run-readelf-macro.sh \ run-native-test.sh run-bug1-test.sh \ dwfl-bug-addr-overflow run-addrname-test.sh \ dwfl-bug-fd-leak dwfl-bug-report \ @@ -96,6 +96,10 @@ check_PROGRAMS += $(asm_TESTS) TESTS += $(asm_TESTS) endif +if ENABLE_DWZ +TESTS += run-readelf-dwz-multi.sh +endif + EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ run-show-die-info.sh run-get-files.sh run-get-lines.sh \ -- 2.7.4