[Patch] ld plugin: Fix known_used with CLAIM_FILE_HOOK_V2 for elf_link_add_archive_symbols [GCC PR122432]
Tobias Burnus
tburnus@baylibre.com
Tue Oct 28 00:35:12 GMT 2025
More information about the Binutils mailing list
Tue Oct 28 00:35:12 GMT 2025
- Previous message (by thread): [Patch] ld plugin: Fix known_used with CLAIM_FILE_HOOK_V2 for elf_link_add_archive_symbols [GCC PR122432]
- Next message (by thread): [Patch] ld plugin: Fix known_used with CLAIM_FILE_HOOK_V2 for elf_link_add_archive_symbols [GCC PR122432]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi HJ, H.J. Lu wrote: > I can't reproduce the issue. If the common symbol comes first is an issue, > you can create a testcase with 2 separate sources: > > 1. a.c only with a common symbol. > 2. b.c uses the common symbol. Unfortunately, it is not that simple - I have now played around with several variants – and the real problem is that 'h = archive_symbol_lookup (…)' tends to be NULL for common symbols. And when turning it into non-NULL, it tends to be h->type == bfd_link_hash_undefined which then gives a call to add_archive_element, which in turn calls the hook with known_used = true. For the here failing testcase of the PR, I get for /liblocoa.a: psb_d_oacc_mlt_v_2_ → h == NULL mpi_fortran_argv_null_ → h->type == bfd_link_hash_common → hook call with known_used = false; second loop ... several with include[i] = 0 until i=10: __psb_d_oacc_vect_mod_MOD___def_init_psb_d_oacc_vect_mod_Psb_d_vect_oacc For all i >= 10 now include[i] = true; Then a third loop: All remaining symbols get include[i] = true. * * * Without the common symbol, the large program has first h == NULL until __psb_d_oacc_vect_mod_MOD___def_init_psb_d_oacc_vect_mod_Psb_d_vect_oacc which is bfd_link_undefine - and for which add_archive_element is called. * * * > Without a testcase There *is* a testcase attached tohttps://gcc.gnu.org/PR122432 > and others can't reproduce the issue, it is > very hard to tell if your patch is correct or not. As you started the discussion at PR122432, I continued there. I hope my annotations on how to check for the correctness help. * * * > Please first create a binutils bug report. I am happy to create a new binutils bug – but I am not sure when. As, currently, the discussion is in the GCC PR, I am unsure when it makes most sense to open the Binutils bug and continue there. Tobias -------------- next part -------------- An HTML attachment was scrubbed... URL: <https://sourceware.org/pipermail/binutils/attachments/20251028/a419f990/attachment.htm>
- Previous message (by thread): [Patch] ld plugin: Fix known_used with CLAIM_FILE_HOOK_V2 for elf_link_add_archive_symbols [GCC PR122432]
- Next message (by thread): [Patch] ld plugin: Fix known_used with CLAIM_FILE_HOOK_V2 for elf_link_add_archive_symbols [GCC PR122432]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list