From nobody Mon Sep 1 20:15:48 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cG0Vs1mlZz678cR; Mon, 01 Sep 2025 20:15:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cG0Vs15txz3fFN; Mon, 01 Sep 2025 20:15:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756757749; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qW9lf7z6+hYuZKAF0GhU51HasIG4HTBZENNRvrfX8b0=; b=CdWw0Ry6Nz+Is0SgiP0+S5UjEHf/v0jwLnB3/C7JP2DzWKthrRK5x2ZHIoIPeGYdstySio 3g9ekJ+R0nX4+IfTpt6Ft1pdb9BSjTlL7TCFKmDRwKShWFhquzQIi1YlHLTn+vjg5flSBz 1STIhePhxgvufXza7qc/ZULrZ4SXfjf7vE8ffstg8wwtUkrsw4x78DbJrH/u81/fHU+3MC bcLbYEez1tGCKka8K3eYtPEnD7qaPXTgfxlAg2NT1t6S7UgjWImjb5C78DnKHvxPG/CQk6 82R8vp47AFQ6e7FAIwraTclazZZMyI5Hv9rwElvgZw1kK6v2qEGb/Ei+JpDFSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756757749; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qW9lf7z6+hYuZKAF0GhU51HasIG4HTBZENNRvrfX8b0=; b=egDse6JiFKwaOQKyomGUcSmEI5F12550nl7FdAeMlz9PkoHcRqh2613lw5hd71yRXYVRgX xTXqbRPDMHQ/VOCczrLok40TF24uBJ78EeO3PvZymFT1NVUk8hpXRr4AM9EnVtGVA/mFFx j7vE400sOoanGhfap847dPsk912+eNqSvMKyrpzN+/9bh25l+a/PeaOyeXLauhQsGHvOdV jzbTl9KgL1ZOzZA0PPLDZpFKqFup54pi375QDyw65PLNj6kYxKSbgS40PIEa6mQjpz84nh aClS+e7Z+I8y4e1TXaRs2d3W0U7EYixImzcKfFEP6COrGjDwvK3pWxHJuQhd4w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1756757749; a=rsa-sha256; cv=none; b=SVXL7rNm/huduyjVbd8KSkjlsRhtdVIIMeAQSFfG4j2gMXktEahPUtWQ1kNa+BBo6Rs6JF XC6Dhchl5PSnYzTaS+oTu68CWlyzcvwd01fXnNQmM/wn4VKLHXjB/m+EWf0yos1FvOKLUa Ck0rDZbFFVk7yvKdFMDUkBUMAw5LaQCrdbErt9hi9UAlIv1Uj5hua/5HfMkINOdjXuszUq O3uZpEbiatsPwt6dRZcgmSh1lULmHuaWpIHKDtKSdhzLeFKej6Xsvk1pDCf1TsnGBz1Uwj ixRJ2sUu2Kc0d3nu/Vonx79Qlfs9co6skNg8/n2u+AUXQV32gNUGn2nO1XSZ4A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cG0Vs09zWzKv; Mon, 01 Sep 2025 20:15:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 581KFmAX007796; Mon, 1 Sep 2025 20:15:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 581KFmqj007793; Mon, 1 Sep 2025 20:15:48 GMT (envelope-from git) Date: Mon, 1 Sep 2025 20:15:48 GMT Message-Id: <202509012015.581KFmqj007793@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 4558fc4f91dc - stable/14 - Merge commit 7a66a26658f4 from llvm git (by Fangrui Song): List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 4558fc4f91dc1d3909083ea664b384595f66c3ae Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=4558fc4f91dc1d3909083ea664b384595f66c3ae commit 4558fc4f91dc1d3909083ea664b384595f66c3ae Author: Ed Maste AuthorDate: 2025-08-28 12:48:17 +0000 Commit: Ed Maste CommitDate: 2025-09-01 20:15:35 +0000 Merge commit 7a66a26658f4 from llvm git (by Fangrui Song): --discard-locals/--discard-all: allow and keep symbols referenced by relocations In GNU objcopy, symbols referenced by relocations are retained. Our COFF (https://reviews.llvm.org/D56480) and Mach-O (https://reviews.llvm.org/D75104) ports port the behavior, but the ELF port doesn't. This PR implements the behavior for ELF. Close #47468 (tcl has a use case that requires `strip -x tclStubLib.o` to strip local symbols not referenced by relocations.) Pull Request: https://github.com/llvm/llvm-project/pull/130704 PR: 258820 Approved by: dim Differential Revision: https://reviews.freebsd.org/D52198 (cherry picked from commit 959806e0a8448ef5df372468b8deddc20d976702) --- .../llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp | 25 +++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/contrib/llvm-project/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp b/contrib/llvm-project/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp index 075455c03415..7de9b4dd2ea1 100644 --- a/contrib/llvm-project/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp +++ b/contrib/llvm-project/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp @@ -368,7 +368,7 @@ static Error updateAndRemoveSymbols(const CommonConfig &Config, // (like GroupSection or RelocationSection). This way, we know which // symbols are still 'needed' and which are not. if (Config.StripUnneeded || !Config.UnneededSymbolsToRemove.empty() || - !Config.OnlySection.empty()) { + !Config.OnlySection.empty() || Config.DiscardMode != DiscardType::None) { for (SectionBase &Sec : Obj.sections()) Sec.markSymbols(); } @@ -390,22 +390,23 @@ static Error updateAndRemoveSymbols(const CommonConfig &Config, if (Config.StripDebug && Sym.Type == STT_FILE) return true; - if ((Config.DiscardMode == DiscardType::All || - (Config.DiscardMode == DiscardType::Locals && - StringRef(Sym.Name).starts_with(".L"))) && - Sym.Binding == STB_LOCAL && Sym.getShndx() != SHN_UNDEF && - Sym.Type != STT_FILE && Sym.Type != STT_SECTION) - return true; - if ((Config.StripUnneeded || Config.UnneededSymbolsToRemove.matches(Sym.Name)) && (!Obj.isRelocatable() || isUnneededSymbol(Sym))) return true; - // We want to remove undefined symbols if all references have been stripped. - if (!Config.OnlySection.empty() && !Sym.Referenced && - Sym.getShndx() == SHN_UNDEF) - return true; + if (!Sym.Referenced) { + if ((Config.DiscardMode == DiscardType::All || + (Config.DiscardMode == DiscardType::Locals && + StringRef(Sym.Name).starts_with(".L"))) && + Sym.Binding == STB_LOCAL && Sym.getShndx() != SHN_UNDEF && + Sym.Type != STT_FILE && Sym.Type != STT_SECTION) + return true; + // We want to remove undefined symbols if all references have been + // stripped. + if (!Config.OnlySection.empty() && Sym.getShndx() == SHN_UNDEF) + return true; + } return false; };