From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-63b70ca0a84so500088b3a.2 for ; Wed, 19 Apr 2023 16:10:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681945805; x=1684537805; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=3maLAXH/d+5z5GjbZI6OxjMyTvfzMeYkkK+lJGGX5Ho=; b=CpA9jmzrWofKmIWSg0MDSiW+UETwkiVAthp1N9Hax14PhDMMGM8UOnfIil7lb8zqBH P2ClbiZ6mK4q7i8URgMDt8B2TP/X2pfSmCX7XmulM7LBXG8xhPJIbjNLovj+Ri/00iXH +OYTmfMpRhQueQGq7ZDjqjCcXir5vmkJm/bnm1YFbbbXgOMvqk1ewtdSs2Ul5wYDpkE9 Za7aAL6tL8farazHL6e4jXZLhofxuZolUH3cLSbUUD2kYcz/E/LJkKx33YImITfV9FzD mvMW1QKdu4b5d20Bg1HPT9NCrtKYOhEotaawPlk8wRyNBmsSYmTDXgHUE6QfaeDwaArP xR8g== 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-Google-Smtp-Source: AKy350YGm4E6kr+K+sof2JR9ENsVDRdR9e4eCh6okSRQQJ/FwGxbQ4lf7Ws710w8b0LEejZyttXqew== 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 From: Alan Modra To: binutils@sourceware.org Subject: PR30343 infrastructure Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 List-Id: 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(). -- Alan Modra Australia Development Lab, IBM