diff options
author | Ian Lance Taylor <iant@golang.org> | 2024-02-29 19:44:19 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2024-02-29 19:45:57 -0800 |
commit | c6d4fb0062c6059fe21968a9fe44c56814c88873 (patch) | |
tree | 7cc8b2014565497d0eb47f4756d52786ed1fa268 /libbacktrace | |
parent | b05f474c8f7768dad50a99a2d676660ee4db09c6 (diff) | |
download | gcc-c6d4fb0062c6059fe21968a9fe44c56814c88873.zip gcc-c6d4fb0062c6059fe21968a9fe44c56814c88873.tar.gz gcc-c6d4fb0062c6059fe21968a9fe44c56814c88873.tar.bz2 |
libbacktrace: read symbol table of debuginfo file
These become another symbol table to search. This is needed if people
use --strip-all rather than --strip-debug when adding a debuglink
section.
Patch is from GitHub user pickard1.
Fixes https://github.com/ianlancetaylor/libbacktrace/issues/113.
* elf.c (elf_add): Add the symbol table from a debuginfo file.
* Makefile.am (MAKETESTS): Add buildidfull and gnudebuglinkfull
variants of buildid and gnudebuglink tests.
(%_gnudebuglinkfull, %_buildidfull): New patterns.
* Makefile.in: Regenerate.
Diffstat (limited to 'libbacktrace')
-rw-r--r-- | libbacktrace/Makefile.am | 16 | ||||
-rw-r--r-- | libbacktrace/Makefile.in | 37 | ||||
-rw-r--r-- | libbacktrace/elf.c | 2 |
3 files changed, 48 insertions, 7 deletions
diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am index 16a72d2..750ed80 100644 --- a/libbacktrace/Makefile.am +++ b/libbacktrace/Makefile.am @@ -257,7 +257,7 @@ b2test_LDFLAGS = -Wl,--build-id b2test_LDADD = libbacktrace_elf_for_test.la check_PROGRAMS += b2test -MAKETESTS += b2test_buildid +MAKETESTS += b2test_buildid b2test_buildidfull if HAVE_DWZ @@ -267,7 +267,7 @@ b3test_LDFLAGS = -Wl,--build-id b3test_LDADD = libbacktrace_elf_for_test.la check_PROGRAMS += b3test -MAKETESTS += b3test_dwz_buildid +MAKETESTS += b3test_dwz_buildid b3test_dwz_buildidfull endif HAVE_DWZ @@ -443,12 +443,16 @@ endif HAVE_PTHREAD if HAVE_OBJCOPY_DEBUGLINK -MAKETESTS += btest_gnudebuglink +MAKETESTS += btest_gnudebuglink btest_gnudebuglinkfull %_gnudebuglink: % $(OBJCOPY) --only-keep-debug $< $@.debug $(OBJCOPY) --strip-debug --add-gnu-debuglink=$@.debug $< $@ +%_gnudebuglinkfull: % + $(OBJCOPY) --only-keep-debug $< $@.debug + $(OBJCOPY) --strip-all --add-gnu-debuglink=$@.debug $< $@ + endif HAVE_OBJCOPY_DEBUGLINK %_buildid: % @@ -457,6 +461,12 @@ endif HAVE_OBJCOPY_DEBUGLINK $< $(OBJCOPY) --strip-debug $< $@ +%_buildidfull: % + ./install-debuginfo-for-buildid.sh \ + "$(TEST_BUILD_ID_DIR)" \ + $< + $(OBJCOPY) --strip-all $< $@ + if HAVE_COMPRESSED_DEBUG ctestg_SOURCES = btest.c testlib.c diff --git a/libbacktrace/Makefile.in b/libbacktrace/Makefile.in index 0eaf4af..7951cf5 100644 --- a/libbacktrace/Makefile.in +++ b/libbacktrace/Makefile.in @@ -134,9 +134,9 @@ TESTS = $(am__append_4) $(MAKETESTS) $(am__EXEEXT_16) @NATIVE_TRUE@@USE_DSYMUTIL_TRUE@ stest.dSYM stest_alloc.dSYM \ @NATIVE_TRUE@@USE_DSYMUTIL_TRUE@ edtest.dSYM edtest_alloc.dSYM @HAVE_BUILDID_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_6 = b2test -@HAVE_BUILDID_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_7 = b2test_buildid +@HAVE_BUILDID_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_7 = b2test_buildid b2test_buildidfull @HAVE_BUILDID_TRUE@@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_8 = b3test -@HAVE_BUILDID_TRUE@@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_9 = b3test_dwz_buildid +@HAVE_BUILDID_TRUE@@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_9 = b3test_dwz_buildid b3test_dwz_buildidfull @HAVE_ELF_TRUE@@NATIVE_TRUE@am__append_10 = btest_lto @NATIVE_TRUE@am__append_11 = btest_alloc stest stest_alloc @HAVE_DWZ_TRUE@@NATIVE_TRUE@am__append_12 = btest_dwz @@ -152,7 +152,7 @@ TESTS = $(am__append_4) $(MAKETESTS) $(am__EXEEXT_16) @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@am__append_21 = \ @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@ ttest.dSYM \ @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@ ttest_alloc.dSYM -@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_22 = btest_gnudebuglink +@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_22 = btest_gnudebuglink btest_gnudebuglinkfull @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_23 = ctestg ctesta @HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@am__append_24 = ctestzstd @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_25 = ctestg_alloc ctesta_alloc @@ -2113,6 +2113,13 @@ b2test_buildid.log: b2test_buildid --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +b2test_buildidfull.log: b2test_buildidfull + @p='b2test_buildidfull'; \ + b='b2test_buildidfull'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) b3test_dwz_buildid.log: b3test_dwz_buildid @p='b3test_dwz_buildid'; \ b='b3test_dwz_buildid'; \ @@ -2120,6 +2127,13 @@ b3test_dwz_buildid.log: b3test_dwz_buildid --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +b3test_dwz_buildidfull.log: b3test_dwz_buildidfull + @p='b3test_dwz_buildidfull'; \ + b='b3test_dwz_buildidfull'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) btest_dwz.log: btest_dwz @p='btest_dwz'; \ b='btest_dwz'; \ @@ -2141,6 +2155,13 @@ btest_gnudebuglink.log: btest_gnudebuglink --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +btest_gnudebuglinkfull.log: btest_gnudebuglinkfull + @p='btest_gnudebuglinkfull'; \ + b='btest_gnudebuglinkfull'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) mtest_minidebug.log: mtest_minidebug @p='mtest_minidebug'; \ b='mtest_minidebug'; \ @@ -2578,12 +2599,22 @@ uninstall-am: @HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@ $(OBJCOPY) --only-keep-debug $< $@.debug @HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@ $(OBJCOPY) --strip-debug --add-gnu-debuglink=$@.debug $< $@ +@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@%_gnudebuglinkfull: % +@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@ $(OBJCOPY) --only-keep-debug $< $@.debug +@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@ $(OBJCOPY) --strip-all --add-gnu-debuglink=$@.debug $< $@ + @NATIVE_TRUE@%_buildid: % @NATIVE_TRUE@ ./install-debuginfo-for-buildid.sh \ @NATIVE_TRUE@ "$(TEST_BUILD_ID_DIR)" \ @NATIVE_TRUE@ $< @NATIVE_TRUE@ $(OBJCOPY) --strip-debug $< $@ +@NATIVE_TRUE@%_buildidfull: % +@NATIVE_TRUE@ ./install-debuginfo-for-buildid.sh \ +@NATIVE_TRUE@ "$(TEST_BUILD_ID_DIR)" \ +@NATIVE_TRUE@ $< +@NATIVE_TRUE@ $(OBJCOPY) --strip-all $< $@ + @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@%_minidebug: % @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@ $(NM) -D $< -P --defined-only | $(AWK) '{ print $$1 }' | sort > $<.dsyms @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@ $(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > $<.fsyms diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c index c506cc2..664937e 100644 --- a/libbacktrace/elf.c +++ b/libbacktrace/elf.c @@ -6872,7 +6872,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, if (symtab_shndx == 0) symtab_shndx = dynsym_shndx; - if (symtab_shndx != 0 && !debuginfo) + if (symtab_shndx != 0) { const b_elf_shdr *symtab_shdr; unsigned int strtab_shndx; |