Since linker calls bfd_plugin_object_p, which calls ld_plugin_object_p,
only for command-line input objects, pass true to ld_plugin_object_p so
that the same input IR file won't be included twice if the new LTO hook,
LDPT_REGISTER_CLAIM_FILE_HOOK_V2 isn't used.
PR ld/32153
* plugin.c (bfd_plugin_object_p): Pass true to ld_plugin_object_p.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit c839a44c39)
Since bfd_section for .strtab isn't set, print the section index
instead. Also, don't return NULL on this error as that results in
multiple mmap/read of the string table. (We could return NULL if we
arranged to set sh_size zero first, but just what we do with fuzzed
object files is of no concern, and terminating the table might make a
faulty object file usable.)
PR 32109
* elf.c (bfd_elf_get_str_section): Remove outdated comment, and
tweak shstrtabsize test to suit. Don't use string tab bfd_section
in error message, use index instead. Don't return NULL on
unterminated string section, terminate it.
(_bfd_elf_get_dynamic_symbols): Similarly terminate string table
section.
(cherry picked from commit db856d4100)
Add a test for PR ld/32083 and xfail the test for GCC without the fix:
commit a98dd536b1017c2b814a3465206c6c01b2890998
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Aug 21 07:25:25 2024 -0700
Update LDPT_REGISTER_CLAIM_FILE_HOOK_V2 linker plugin hook
PR ld/32083
* testsuite/ld-plugin/common-2a.c: New file.
* testsuite/ld-plugin/common-2b.c: Likewise.
* testsuite/ld-plugin/lto.exp: Run PR ld/32083 test.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit eb53cbeca8)
Linker checks if a symbol in an archive member is a real definition, not
common, before including the archive member in the link output so that
only a real definition in archive will override the common symbol in
object file. Add an LTO test to verify that a real definition in archive
overrides the common symbol in object file.
* testsuite/ld-plugin/common-1.c: New file.
* testsuite/ld-plugin/definition-1.c: Likewise.
* testsuite/ld-plugin/lto.exp: Run common tests.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit 8be33827cd)
When plugin_object_p is called by elf_link_is_defined_archive_symbol to
check if a symbol in archive is a real definition, set archive member
plugin_format to bfd_plugin_yes_unused to avoid including the unused LTO
archive members in linker output. When plugin_object_p is called as
known used, call plugin claim_file if plugin_format is bfd_plugin_unknown
or bfd_plugin_yes_unused.
To get the proper support for archives with LTO common symbols with GCC,
the GCC fix for
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116361
is needed.
bfd/
PR ld/32083
* archures.c (bfd_arch_get_compatible): Treat bfd_plugin_yes_unused
the same as bfd_plugin_yes.
* elflink.c (elf_link_is_defined_archive_symbol): Likewise.
* bfd.c (bfd_plugin_format): Add bfd_plugin_yes_unused.
* plugin.c (try_claim): Try claim_file_v2 first.
* bfd-in2.h: Regenerated.
ld/
PR ld/32083
* plugin.c (plugin_call_claim_file): Add an argument to return
if LDPT_REGISTER_CLAIM_FILE_HOOK_V2 is used.
(plugin_object_p): When KNOWN_USED is false, we call plugin
claim_file if plugin_format is bfd_plugin_unknown and set
plugin_format to bfd_plugin_yes_unused on LTO object. When
KNOWN_USED is true, we call plugin claim_file if plugin_format
is bfd_plugin_unknown or bfd_plugin_yes_unused.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit a6f8fe0a9e)
When VexVVVV handling was re-worked, .insn broke: When an opcode
extension is in use, VexVVVV_DST needs using now, as ModR/M.reg is
already occupied, matching what c8866e3ec5 ("x86: Drop using
extension_opcode to encode vvvv register") did.
While adding (bad) POP2 forms, also slightly adjust existing ones:
No need to use XMM registers, and no need to specify %r8 when really
%rax is meant twice (EVEX.vvvv not really being the culprit there, or
else EVEX.V' would also have needed mentioning).
Add PR ld/32067 tests with the compiler driver since the -plugin option
is needed to trigger this --oformat binary bug.
PR ld/32067
* testsuite/ld-i386/i386.exp: Run PR ld/32067 test.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/start.s: Add .note.GNU-stack section.
* testsuite/ld-x86-64/pr32067.s: New file.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit 602f5cf7e3)
The direct fix for this segfault is to test for a non-NULL bed in
_bfd_elf_link_keep_memory, but also there isn't much point in running
code for LTO if the output is binary.
PR 32067
* elflink.c (_bfd_elf_link_keep_memory): Test for non-NULL bed.
(elf_link_add_object_symbols): Don't run the loop setting
non_ir_ref_regular if the output hash table is not ELF.
(cherry picked from commit ec8f5671b4)