From patchwork Fri Mar 1 03:47:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 1906538 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=golang-org.20230601.gappssmtp.com header.i=@golang-org.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=eaICYlxU; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TmDZB38qJz23l2 for ; Fri, 1 Mar 2024 14:47:44 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 43AB83858C66 for ; Fri, 1 Mar 2024 03:47:42 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-yw1-x112a.google.com (mail-yw1-x112a.google.com [IPv6:2607:f8b0:4864:20::112a]) by sourceware.org (Postfix) with ESMTPS id DFD223858D34 for ; Fri, 1 Mar 2024 03:47:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DFD223858D34 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=golang.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=golang.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DFD223858D34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::112a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709264843; cv=none; b=Hi3BZiZ9WZuC6r1FtY0CKsFCT4HXIU45MbYSK7BHNBQWleyLPdAxDCPhETooVlk2vUiKIE/WNnwzcag4SsEymcMDsjEgQ3f9x/AVHVIe+KEtIKfW7/v8WpB1cZBpRlXaITLcW0++7nPTgfDjMn2cTXLq3kgeOeQTx4dfqLsVMdM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709264843; c=relaxed/simple; bh=914ppJWHI/1aKIG6gm5RB95RGELRus5gFrvxjhyrviQ=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=ujU5FPvK/4rT1bFyVsE9ICF9KLVuDVrWasA50ZDaJLB/Yx0HgP/rmYKKdMGRfXfEBt++8BM4mt9l9UskAqEXAvhNxYDVVPvtplo7MgysYhecftR7OEmlVXm43ISnYzhkKFsvB+bpo4oFOcXfndBDQWFKbwob+roXr13kcGIM4H0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-6095dfcb461so16180947b3.2 for ; Thu, 29 Feb 2024 19:47:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golang-org.20230601.gappssmtp.com; s=20230601; t=1709264841; x=1709869641; darn=gcc.gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=W8yOpiZwCndH9J2+eiWVHGGRzURU1RZsoDJmFw1i85g=; b=eaICYlxU0xk5R05CjH3IG2edWblKU7hvIC9noayoAVWjh5OAKVZOSeE9BMtcF1XHye HelT5z9jplzMtxK+Zv3zDRhN4yPUMjx+hKWNYTRl1zdfw9IfYMXcBIVcbsGzLwCrbgRD M1cX8lnw0AfhZWSPsS3KmUpqhUv0zVUXS8GTLy0sPUmVAo16N4/Q8T01d4oC0E0UiDbW BsFlF8JpswoD0cQRSu+VT0oDrU8yiZP5nUlmWrjrkV7JU/dEqZMuqEL3UAIJY/z2VddJ A2m8vC+5Av3OjNdgFoETevoWtBlSCiiRCx6vJPs7x8ba33U4wZFcKz1WnXcVyuKovNmw pexA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709264841; x=1709869641; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=W8yOpiZwCndH9J2+eiWVHGGRzURU1RZsoDJmFw1i85g=; b=ZpdVpXUfEiPQQXPMgexxieevtG31czWjvkQT2Sh6xXZMCiJ5DXGoxlbC0BZzOj02yk actnEUGyTQHjYEb6j66ODt/SDet8phGr0swVfQ6iRifK6zhwSaOwYzbf9VNkyPMaqwim 7fbU/9FoY5HZYhjOEtXvSFeTonOpN0U3UjfXgkUtdqZQ6KecM0ySzVvRt7RHJ184N2w7 jvbtnco7yYhMSH/20g2H583kDXkzbo1VPbVeYoQxPAj/83Gn2ZCTgbfhya/8mA9p/OjV FZ1Nj8XRQWD2f6gyaCuLZeGQrN1B4qJ61CbV1zYIA24P4D8VvbzHWvfBwVOcOG9Jm6tj GHpg== X-Gm-Message-State: AOJu0YwttCSI0yTFWqnJWQ+AowTYgcHJFqcGxobInse/SG8bvkxQbNtz R2WEF653sUcs4ao0snQBDTuwN2RfTvalrQQGYYL2AX40T0oFJovjKGpu24vAh2/ehVgGJs9uXTI Gky3APB90aWK/MtPc66nJKAFJERD5B2mh0HFLRW4Pm/MIk9TwaOM= X-Google-Smtp-Source: AGHT+IGEN+ax8/Rw9/fPJq80MzEbAdlUjLY2AC6snNYsg28OukAkTxjKI4Aq+9qIlh4J+j3pL/I2GfWpQjj2VyRKvbc= X-Received: by 2002:a25:ab47:0:b0:dc6:c2b2:c039 with SMTP id u65-20020a25ab47000000b00dc6c2b2c039mr353996ybi.41.1709264840797; Thu, 29 Feb 2024 19:47:20 -0800 (PST) MIME-Version: 1.0 From: Ian Lance Taylor Date: Thu, 29 Feb 2024 19:47:09 -0800 Message-ID: Subject: libbacktrace patch committed: Read symbol table of debuginfo file To: gcc-patches X-Spam-Status: No, score=-12.0 required=5.0 tests=DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org This patch to libbacktrace reads symbol tables from debuginfo files. These become another symbol table to search. This is needed if people use --strip-all rather than --strip-debug when adding a debuglink section. This fixes https://github.com/ianlancetaylor/libbacktrace/issues/113. Bootstrapped and ran libbacktrace and libgo tests on x86_64-pc-linux-gnu. Committed to mainline. Ian * 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. 24810fbf7b0ce274dfa46cc362305ac77ee5a72c diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am index 16a72d2abf7..750ed80ed05 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/elf.c b/libbacktrace/elf.c index c506cc29fe1..664937e1438 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;