https://sourceware.org/bugzilla/show_bug.cgi?id=33863
--- Comment #1 from Martin Mirchev <martin.mirchev at u dot nus.edu> ---
Confirmed on master 1ec1cee48577c7b1960ddce5a6054b3f9fab6ef5 (GNU ld
2.47.50.20261027) and on Ubuntu 22.04's ld 2.38, on a plain x86-64 host with
no -march setting. The reproducer does not need a -march=x86-64-v3 system:
glibc's crt1.o already has "x86 ISA needed: x86-64-baseline", so
$ echo 'int main(void) { return 0; }' > hello.c
$ gcc -Wl,-z,x86-64-baseline hello.c
ld: BFD (GNU Binutils) 2.47.50.20261027 internal error, aborting at
bfd/elfxx-x86.c:4160 in _bfd_x86_elf_merge_gnu_properties
$ gcc -Wl,-z,x86-64-v2 hello.c # works
Without gcc, two objects that each have a GNU_PROPERTY_X86_ISA_1_NEEDED note
(needed.s and needed2.s in the attached ld-x86-64-baseline.tar.gz) are enough:
$ ld -z x86-64-baseline -o out needed.o needed2.o -> internal error, exit 1
$ ld [-z x86-64-v2|v3|v4] -o out needed.o needed2.o -> exit 0
(with a single input the merge hook is not called and the link works)
Cause: ld/emulparams/x86-64-level.sh sets params.isa_level = 1 for
-z x86-64-baseline. _bfd_x86_elf_setup_gnu_properties maps 1 to
GNU_PROPERTY_X86_ISA_1_BASELINE, but the GNU_PROPERTY_X86_ISA_1_NEEDED
switch in _bfd_x86_elf_merge_gnu_properties (bfd/elfxx-x86.c:4146-4161) only
has cases 0, 2, 3 and 4, so level 1 reaches "default: abort ()". The option
is documented in ld.texi ("x86-64-baseline generates
GNU_PROPERTY_X86_ISA_1_BASELINE") and in ld --help, so this is the
documented use. The merge switch probably needs a case for level 1 like
the one in the setup function.
Note for the original reporter: -z x86-64-baseline ORs the baseline bit
into the note. It does not remove the v2/v3 bits from the inputs, so even
after a fix it will not drop those requirements.
This issue was found by an LLM-Enhanced Static Analysis Engine and verified
manually.
--
You are receiving this mail because:
You are on the CC list for the bug.