[PATCH v3] elf: Don't set its DT_VERSYM entry for unversioned symbol

Andreas Schwab schwab@suse.de
Tue Nov 11 10:46:30 GMT 2025


On Okt 31 2025, H.J. Lu wrote:

> 1. Referenced symbol without '@' has no version.
> 2. Defined symbol without the .symver directive has no version if there
> is no linker version script.
>
> Symbol without version shouldn't have the base version in its DT_VERSYM
> entry.  Instead, its DT_VERSYM entry should be all zero to indicate that
> the symbol doesn't have a version.

This breaks the testsuite of mold:

 38/428 Test  #38: x86_64-arch-x86_64-reloc ..............................***Failed    0.09 sec
++ dirname /home/abuild/rpmbuild/BUILD/mold-2.40.4.60.gad08999-build/mold-2.40.4.60.gad08999/test/arch-x86_64-reloc.sh
+ . /home/abuild/rpmbuild/BUILD/mold-2.40.4.60.gad08999-build/mold-2.40.4.60.gad08999/test/common.inc
++ export LC_ALL=C
++ LC_ALL=C
++ '[' -z x86_64 ']'
++ '[' -z '' ']'
++ TESTDIR=out/test/x86_64
++ CC=cc
++ CXX=c++
++ GCC=gcc
++ GXX=g++
++ OBJDUMP=objdump
++ OBJCOPY=objcopy
++ STRIP=strip
++ QEMU=
+++ basename /home/abuild/rpmbuild/BUILD/mold-2.40.4.60.gad08999-build/mold-2.40.4.60.gad08999/test/arch-x86_64-reloc.sh .sh
++ testname=arch-x86_64-reloc
++ t=out/test/x86_64/arch-x86_64-reloc
++ mkdir -p out/test/x86_64/arch-x86_64-reloc
++ case $MACHINE in
++ tlsdesc_opt=-mtls-dialect=gnu2
+++ uname
++ '[' Linux = FreeBSD ']'
++ trap 'on_error $LINENO' ERR
++ trap on_exit EXIT
++ echo -n 'Testing arch-x86_64-reloc ... '
Testing arch-x86_64-reloc ... ++ set -o pipefail
++ set -x
+ cat
+ cc -fPIC -c -o out/test/x86_64/arch-x86_64-reloc/a.o -x assembler -
+ cc -fPIC -c -o out/test/x86_64/arch-x86_64-reloc/b.o -xc -
+ cat
+ cc -shared -o out/test/x86_64/arch-x86_64-reloc/c.so out/test/x86_64/arch-x86_64-reloc/a.o out/test/x86_64/arch-x86_64-reloc/b.o -Wl,-z,noexecstack
+ cat
+ cc -B. -o out/test/x86_64/arch-x86_64-reloc/exe out/test/x86_64/arch-x86_64-reloc/c.so out/test/x86_64/arch-x86_64-reloc/d.s -no-pie
mold: error: undefined symbol: print
>>> referenced by /tmp/ccfsY4zd.o:(.text)
>>>               /tmp/ccfsY4zd.o
collect2: error: ld returned 1 exit status
++ on_error 43
++ code=1
++ echo 'command failed: 43: $CC -B. -o $t/exe $t/c.so $t/d.s -no-pie'
command failed: 43: $CC -B. -o $t/exe $t/c.so $t/d.s -no-pie
++ trap - EXIT
++ exit 1

Is this a bug in mold?

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


More information about the Binutils mailing list