From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 43B5C3857369 for ; Thu, 23 Jun 2022 15:14:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 43B5C3857369 Received: by mail-pf1-x42d.google.com with SMTP id i64so19389182pfc.8 for ; Thu, 23 Jun 2022 08:14:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iMVyKj2pAeUW9cBZ02XI1XaIrNB/e2xB0v+Hby9Hv20=; b=7jj+tYV4M0RLk6K04m3PzbYmHTm+w1+Y+yNGlhxoUUyRk8CZ3n99whtSCoZcxKPu3l KTs3CBWlQa/m1NppMiKVBg9CGi4C0JUfxdVYLQ6CRP2XvuZXb/cbaWshjthbCAPbuTYi qULXf6ivqvt4CnsRbmaU2VYGsmLnsXG2MC3lY4cSEe7bCqRyrKuuUaL2SNxIcFF/QW7T w9fQmBGIMyLTrNcrlSaS9tNYIdLX+iU+bS45I9lAkZ4LWHkqk9US3EbbYetjve7NYAUw hRreDOcyAZCtf3HTn9LpdUAsu/AQqta8uZOTDi6TFrCf0qy2gWrp5BXnX4JkAvKgn7d7 znlQ== X-Gm-Message-State: AJIora82+/ah3nd72qQShkITWT7O9+qIZMneMINZfzT7epaZppYnjDOG O20vU4NpMDUhXWDL2LrirbIFrOn5wC0x2hCM X-Google-Smtp-Source: AGRyM1t1Em7+QiBLNKNrz5WBziEtgG9AQPjARjIDTtokPjqxeKlcl14eLLkFvuUXWCYVf+NaxlaUOw== X-Received: by 2002:a05:6a00:3006:b0:525:266a:852e with SMTP id ay6-20020a056a00300600b00525266a852emr20483667pfb.60.1655997274235; Thu, 23 Jun 2022 08:14:34 -0700 (PDT) Received: from localhost (221x248x146x74.ap221.ftth.ucom.ne.jp. [221.248.146.74]) by smtp.gmail.com with UTF8SMTPSA id o12-20020a17090aac0c00b001eac661025fsm2009155pjq.29.2022.06.23.08.14.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Jun 2022 08:14:34 -0700 (PDT) From: Tatsuyuki Ishi To: binutils@sourceware.org Cc: amodra@gmail.com, jbeulich@suse.com, i@maskray.me, Tatsuyuki Ishi Subject: [PATCH v2 4/6] ld: Discard LLVM_ADDRSIG sections. Date: Fri, 24 Jun 2022 00:13:52 +0900 Message-Id: <20220623151353.62139-5-ishitatsuyuki@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623151353.62139-1-ishitatsuyuki@gmail.com> References: <20220623151353.62139-1-ishitatsuyuki@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jun 2022 15:14:37 -0000 The symbol indices in addrsig sections requires update in the case of a partial link, which we currently cannot do. Now that bfd is able to insert a correct sh_link entry for the addrsig section, this will break the final linker's heuristic [1] that discards such corrupt section. As such, strip this section explicitly for ld -r. [1]: https://github.com/llvm/llvm-project/blob/09c2b7c35af8c4bad39f03e9f60df8bd07323028/lld/ELF/InputFiles.cpp#L540-L554 --- ld/ldlang.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ld/ldlang.c b/ld/ldlang.c index 839535bdb73..ba2d350bbd9 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -2516,6 +2516,13 @@ lang_discard_section_p (asection *section) && link_info.resolve_section_groups) discard = true; + /* Discard .llvm_addrsig sections. We don't do the additional processing + to keep the symbol indices correct, and when doing a partial link this + will end up getting the wrong information to the final linker. */ + if (bfd_get_flavour (section->owner) == bfd_target_elf_flavour + && elf_section_type (section) == SHT_LLVM_ADDRSIG) + discard = true; + /* Discard debugging sections if we are stripping debugging information. */ if ((link_info.strip == strip_debugger || link_info.strip == strip_all) -- 2.36.1