[PATCH] ld: Properly override compiler flags in tests

Sam James sam@gentoo.org
Sat Aug 16 12:21:36 GMT 2025


"H.J. Lu" <hjl.tools@gmail.com> writes:

> Some tests need to be compiled with additional flags.  When binutils is
> built and compiled with
>
> CC="gcc -fsanitize=address,undefined" CXX="g++ -fsanitize=address,undefined"
>
> [...]

It causes some improvements but some regressions for me:

-# of expected passes           3043
-# of unexpected failures       64
+# of expected passes           3063
+# of unexpected failures       44
 # of expected failures         60
 # of untested testcases                29
 # of unsupported tests         29

(The existing failures are because of an unrelated issue.)

A new failure:

gcc  -B/tmp/build2/ld/tmpdir/ld/ -I/home/sam/git/binutils-gdb/ld/testsuite/ld-elf -g -O2 -fno-sanitize=all   -fsanitize=address,undefined -c -fno-lto -fno-PIE  -fno-sanitize=all  -fno-sanitize=all -c /home/sam/git/binutils-gdb/ld/testsuite/ld-elf/dl6amain.c -o tmpdir/dl6amain.o
Executing on host: sh -c {gcc  -B/tmp/build2/ld/tmpdir/ld/ -I/home/sam/git/binutils-gdb/ld/testsuite/ld-elf -g -O2 -fno-sanitize=all   -fsanitize=address,undefined -c -fno-lto -fno-PIE  -fno-sanitize=all  -fno-sanitize=all -c /home/sam/git/binutils-gdb/ld/testsuite/ld-elf/dl6amain.c -o tmpdir/dl6amain.o 2>&1}  /dev/null ld.tmp (timeout = 300)
spawn [open ...]
gcc  -B/tmp/build2/ld/tmpdir/ld/  -fsanitize=address,undefined  -fno-sanitize=all  -L/usr/local/x86_64-pc-linux-gnu/lib64 -L/usr/local/lib64 -L/lib64 -L/usr/lib64 -L/usr/local/x86_64-pc-linux-gnu/lib -L/usr/local/lib -L/lib -L/usr/lib    -o tmpdir/dl6a2  -L/home/sam/git/binutils-gdb/ld/testsuite/ld-elf -no-pie -Wl,--no-as-needed,-Bsymbolic-functions -ldl tmpdir/dl6amain.o
Executing on host: sh -c {gcc  -B/tmp/build2/ld/tmpdir/ld/  -fsanitize=address,undefined  -fno-sanitize=all  -L/usr/local/x86_64-pc-linux-gnu/lib64 -L/usr/local/lib64 -L/lib64 -L/usr/lib64 -L/usr/local/x86_64-pc-linux-gnu/lib -L/usr/local/lib -L/lib -L/usr/lib    -o tmpdir/dl6a2  -L/home/sam/git/binutils-gdb/ld/testsuite/ld-elf -no-pie -Wl,--no-as-needed,-Bsymbolic-functions -ldl tmpdir/dl6amain.o  2>&1}  /dev/null ld.tmp (timeout = 300)
spawn [open ...]
Running: tmpdir/dl6a2 > tmpdir/dl6a2.out
==592377==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
FAIL: Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.

libdl1.so is built with sanitizers enabled. The change exposes some
missing $NOSANITIZE_CFLAGS we need to sprinkle around.


More information about the Binutils mailing list