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 #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.
This commit is contained in:
Ian Lance Taylor
2024-02-29 19:44:19 -08:00
parent 14818b7783
commit 36cfdc18ed
3 changed files with 48 additions and 7 deletions

View File

@@ -258,7 +258,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
@@ -268,7 +268,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
@@ -444,12 +444,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: %
@@ -458,6 +462,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