From patchwork Wed Apr 19 23:10:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 85641 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp722059vqo; Wed, 19 Apr 2023 16:10:16 -0700 (PDT) X-Google-Smtp-Source: AKy350b/4I9dge6ipGL/9kOKLoaaxbrXavaAHZVrodvsWOrfPmW8HTW/80jV9cpmLdzpuvrNMfPI X-Received: by 2002:a17:906:fa18:b0:928:796d:71e8 with SMTP id lo24-20020a170906fa1800b00928796d71e8mr15428860ejb.3.1681945816468; Wed, 19 Apr 2023 16:10:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681945816; cv=none; d=google.com; s=arc-20160816; b=j9D2K+J/8kvo/sRH1hsEJGC8K0r6On6Dr5S1w1vowPrNz6ixTdBJ8orQi9+H5M86HM 30QU6giDpxD86xV36xuAFJ0M+GRRXcUQU9Pc5SQOY6L/oMHNWhL2+Cf3ZU6BMRYYMik/ 4Qv9WJwP1/tl9aydbAk2DT8GDJBSDdoa8wbijLgDlBINm8sjUEXfeUhfRc6JKnLFqLCp KzT4wv+SYDxzTM2Mn2iR/QMEC3SuzNUH7QaKhG5dwVQRN2tTradzXpgoXMTSo3ae7FxX WKa9tVbIaA7yqnlLz6rn3BuV7zxgqAMfNk310hqShScivpcFUeFUKEjIyTU6brj6W0nG 30Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=3maLAXH/d+5z5GjbZI6OxjMyTvfzMeYkkK+lJGGX5Ho=; b=Q86KxNP9xg5xkrZ++soylaYAi3l73FdxDhzeN4KWT9euCTRxpI1LBDzjI02nE+MsgP ddkTsVubIG0XhKADgzqz4YrK8l5Mkmtxwy/RIv2NFD9YqxAaa3TyZAOwrpUY7w3Sz6qb W8Cx6M+26WmJ7p+DxO0eBKmdhKCd4zMZtXmXtUaeHjfFlS+NQ7ceOZr73wjv2zVDIxXP PPsgOuhGdP4PwTE/BFI1m6DKrhgFTsUNr3ihpefFpkvfdBwoxfTVhQ0+RRiD6sg5M0gX pgt0xGZfoelFzfk1wMQbwN62DMPHxff4Xsjo+6bqCRZjr+Lmul0ltvka0lFgtdlNXeTo ubTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="Spg/xxgZ"; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id j24-20020a17090643d800b0094f75216420si43353ejn.724.2023.04.19.16.10.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 16:10:16 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="Spg/xxgZ"; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6A1083858413 for ; Wed, 19 Apr 2023 23:10:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A1083858413 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681945815; bh=3maLAXH/d+5z5GjbZI6OxjMyTvfzMeYkkK+lJGGX5Ho=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Spg/xxgZ01vVw1VbCS1YK/yWgXKqhsNf10JXWVx4IJMW7GxQIseDATdRFE3EC3RLX ftVnL7+jHCnek+nazBag1qhfmC17L3FHyixv58dHZqIjRw8x/fXd4hF8uUHVaOSmlf u0PvNA1paUWY6WzSDEkzoTMU0I1ons/MLeLWWyK4= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 6B5863858D33 for ; Wed, 19 Apr 2023 23:10:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6B5863858D33 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-63b70ca0a84so500088b3a.2 for ; Wed, 19 Apr 2023 16:10:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681945805; x=1684537805; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3maLAXH/d+5z5GjbZI6OxjMyTvfzMeYkkK+lJGGX5Ho=; b=Q5qdok0tA1MiK8UCSONDHMrGiW/5xqYoT+r6bWAKlbmZdsevLalu0fXKThDL+RJw+V kU2Sk3cWDpxJd8ceKWEv6Zpg4sqwC2+Hy5mVsXzGhP7KcT4luWJa1B6zACSENOD0GD91 XGH07ZCauGAHAF98TFknICTqKjbZxIrq2XCxKplRQQPAEfggIiJossJlP3w2Ui7yAusO QI2Hgd1kNhSGqwB8S0mZplg8Z5e9OQMGTwkadPNILumQrRK7t+oMcVkhD60+ijbLqBdO gz7VrrjWeXnDVFZu5gxpMRvfIF5urzRX60ZdTN6Ss+dZYIT/kkgpsTqFfNZ/luKquhWA RpvQ== X-Gm-Message-State: AAQBX9ePt94Nrxm+kGKrEfsQB6homQAygEFCwpBf1ihSWE/VH7y6dide IFnQP2PCT2pN/k5f7apDVcAYhH4jPCw= X-Received: by 2002:a05:6a20:7345:b0:ee:af32:754b with SMTP id v5-20020a056a20734500b000eeaf32754bmr327959pzc.2.1681945805629; Wed, 19 Apr 2023 16:10:05 -0700 (PDT) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id t186-20020a632dc3000000b0051fa7704c1asm1688841pgt.47.2023.04.19.16.10.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 16:10:05 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id D550D1142CAE; Thu, 20 Apr 2023 08:40:02 +0930 (ACST) Date: Thu, 20 Apr 2023 08:40:02 +0930 To: binutils@sourceware.org Subject: PR30343 infrastructure Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3035.0 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-Patchwork-Original-From: Alan Modra via Binutils From: Alan Modra Reply-To: Alan Modra Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763648016332802272?= X-GMAIL-MSGID: =?utf-8?q?1763648016332802272?= Make ldemul_before_plugin_all_symbols_read more useful. This isn't a fix for the PR, but will be required I think. * ldlang.c (lang_process): Move call to ldemul_before_plugin_all_symbols_read outside BFD_SUPPORTS_PLUGINS. Allow backends to add to gc_sym_list before handling entry sym. * ldelf.c (ldelf_before_plugin_all_symbols_read): Test lto_plugin_active. diff --git a/ld/ldelf.c b/ld/ldelf.c index eff6693e052..f9a6819366f 100644 --- a/ld/ldelf.c +++ b/ld/ldelf.c @@ -1215,7 +1215,8 @@ ldelf_before_plugin_all_symbols_read (int use_libpath, int native, { struct elf_link_hash_table *htab = elf_hash_table (&link_info); - if (!is_elf_hash_table (&htab->root)) + if (!link_info.lto_plugin_active + || !is_elf_hash_table (&htab->root)) return; htab->handling_dt_needed = true; diff --git a/ld/ldlang.c b/ld/ldlang.c index b684e2d479a..006031b5a65 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -7964,14 +7964,14 @@ lang_process (void) statements we can give values to symbolic origin/length now. */ lang_do_memory_regions (true); + ldemul_before_plugin_all_symbols_read (); + #if BFD_SUPPORTS_PLUGINS if (link_info.lto_plugin_active) { lang_statement_list_type added; lang_statement_list_type files, inputfiles; - ldemul_before_plugin_all_symbols_read (); - /* Now all files are read, let the plugin(s) decide if there are any more to be added to the link before we call the emulation's after_open hook. We create a private list of @@ -8074,17 +8074,17 @@ lang_process (void) } #endif /* BFD_SUPPORTS_PLUGINS */ - /* Make sure that nobody has tried to add a symbol to this list - before now. */ - ASSERT (link_info.gc_sym_list == NULL); + struct bfd_sym_chain **sym = &link_info.gc_sym_list; + while (*sym) + sym = &(*sym)->next; - link_info.gc_sym_list = &entry_symbol; + *sym = &entry_symbol; if (entry_symbol.name == NULL) { - link_info.gc_sym_list = ldlang_undef_chain_list_head; + *sym = ldlang_undef_chain_list_head; - /* entry_symbol is normally initialied by a ENTRY definition in the + /* entry_symbol is normally initialised by an ENTRY definition in the linker script or the -e command line option. But if neither of these have been used, the target specific backend may still have provided an entry symbol via a call to lang_default_entry().