From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id BFDF73858C20; Wed, 19 Apr 2023 23:34:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BFDF73858C20 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Alan Modra To: bfd-cvs@sourceware.org Subject: [binutils-gdb] PR30343 infrastructure X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/master X-Git-Oldrev: 329dd2b6fcad4b3f1c4b0d443381f7c68ef18a9f X-Git-Newrev: 2605f35cda6ec0710ad87e14912dd4ee537e674e Message-Id: <20230419233450.BFDF73858C20@sourceware.org> Date: Wed, 19 Apr 2023 23:34:50 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Apr 2023 23:34:50 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D2605f35cda6e= c0710ad87e14912dd4ee537e674e commit 2605f35cda6ec0710ad87e14912dd4ee537e674e Author: Alan Modra Date: Wed Apr 19 14:21:15 2023 +0930 PR30343 infrastructure =20 Make ldemul_before_plugin_all_symbols_read more useful. =20 * ldlang.c (lang_process): Move call to ldemul_before_plugin_all_symbols_read outside BFD_SUPPORTS_PLUG= INS. 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: --- ld/ldelf.c | 3 ++- ld/ldlang.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) 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 =3D elf_hash_table (&link_info); =20 - if (!is_elf_hash_table (&htab->root)) + if (!link_info.lto_plugin_active + || !is_elf_hash_table (&htab->root)) return; =20 htab->handling_dt_needed =3D 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); =20 + 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; =20 - 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 */ =20 - /* Make sure that nobody has tried to add a symbol to this list - before now. */ - ASSERT (link_info.gc_sym_list =3D=3D NULL); + struct bfd_sym_chain **sym =3D &link_info.gc_sym_list; + while (*sym) + sym =3D &(*sym)->next; =20 - link_info.gc_sym_list =3D &entry_symbol; + *sym =3D &entry_symbol; =20 if (entry_symbol.name =3D=3D NULL) { - link_info.gc_sym_list =3D ldlang_undef_chain_list_head; + *sym =3D ldlang_undef_chain_list_head; =20 - /* 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().