main (via pkgbase use): -fsanitize=address use ends up with /usr/lib/libexecinfo.so.1 reference (not just /lib/* references)

From: Mark Millard <marklmi_at_yahoo.com>
Date: Wed, 21 Feb 2024 20:11:31 UTC
On a pkgbase official-build based system I ended up with "ldd a.out"
showing:

libexecinfo.so.1 => /usr/lib/libexecinfo.so.1 (0x5430bd2d7000)

via the following (the -lsys is for __elf_aux_vector binding currently):


# more main.c
int main(void) { return 0; }

# cc -v -fsanitize=address -lsys main.c

# cc -v -fsanitize=address -lsys main.c
FreeBSD clang version 17.0.6 (https://github.com/llvm/llvm-project.git llvmorg-17.0.6-0-g6009708b4367)
Target: aarch64-unknown-freebsd15.0
Thread model: posix
InstalledDir: /usr/bin
 "/usr/bin/cc" -cc1 -triple aarch64-unknown-freebsd15.0 -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name main.c -mrelocation-model static -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -target-feature +neon -target-feature +v8a -target-abi aapcs -debugger-tuning=gdb -v -fcoverage-compilation-dir=/root/c_tests -resource-dir /usr/lib/clang/17 -internal-isystem /usr/lib/clang/17/include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/root/c_tests -ferror-limit 19 -fsanitize=address -fsanitize-system-ignorelist=/usr/lib/clang/17/share/asan_ignorelist.txt -fno-sanitize-memory-param-retval -fsanitize-address-use-after-scope -fsanitize-address-globals-dead-stripping -fno-assume-sane-operator-new -fno-signed-char -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/main-b64c2c.o -x c main.c
clang -cc1 version 17.0.6 based upon LLVM 17.0.6 default target aarch64-unknown-freebsd15.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/clang/17/include
 /usr/include
End of search list.
 "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --enable-new-dtags -o a.out /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib --whole-archive /usr/lib/clang/17/lib/freebsd/libclang_rt.asan_static-aarch64.a --no-whole-archive --whole-archive /usr/lib/clang/17/lib/freebsd/libclang_rt.asan-aarch64.a --no-whole-archive --export-dynamic -lsys /tmp/main-b64c2c.o --no-as-needed -lpthread -lrt -lm -lexecinfo -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o

(Note the -lexecinfo in the /usr/bin/ld command above.)

# ldd -a a.out
a.out:
        libsys.so.7 => /lib/libsys.so.7 (0x513cd0e45000)
        libthr.so.3 => /lib/libthr.so.3 (0x513ccfa85000)
        librt.so.1 => /lib/librt.so.1 (0x513cd000a000)
        libm.so.5 => /lib/libm.so.5 (0x513cd239b000)
        libexecinfo.so.1 => /usr/lib/libexecinfo.so.1 (0x513cd0f39000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x513cd131a000)
        libc.so.7 => /lib/libc.so.7 (0x513cd2bba000)
/lib/libthr.so.3:
        libc.so.7 => /lib/libc.so.7 (0x513cd2bba000)
        libsys.so.7 => /lib/libsys.so.7 (0x513cd0e45000)
/lib/librt.so.1:
        libthr.so.3 => /lib/libthr.so.3 (0x513ccfa85000)
        libc.so.7 => /lib/libc.so.7 (0x513cd2bba000)
/lib/libm.so.5:
        libc.so.7 => /lib/libc.so.7 (0x513cd2bba000)
/usr/lib/libexecinfo.so.1:
        libelf.so.2 => /lib/libelf.so.2 (0x513cd3cd8000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x513cd131a000)
        libc.so.7 => /lib/libc.so.7 (0x513cd2bba000)
/lib/libgcc_s.so.1:
        libc.so.7 => /lib/libc.so.7 (0x513cd2bba000)
/lib/libc.so.7:
        libsys.so.7 => /lib/libsys.so.7 (0x513cd0e45000)
/lib/libelf.so.2:
        libc.so.7 => /lib/libc.so.7 (0x513cd2bba000)


By contrast, with just "-fsanitize=address" eliminated:

# cc -v -lsys main.c
FreeBSD clang version 17.0.6 (https://github.com/llvm/llvm-project.git llvmorg-17.0.6-0-g6009708b4367)
Target: aarch64-unknown-freebsd15.0
Thread model: posix
InstalledDir: /usr/bin
 "/usr/bin/cc" -cc1 -triple aarch64-unknown-freebsd15.0 -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name main.c -mrelocation-model static -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -target-feature +neon -target-feature +v8a -target-abi aapcs -debugger-tuning=gdb -v -fcoverage-compilation-dir=/root/c_tests -resource-dir /usr/lib/clang/17 -internal-isystem /usr/lib/clang/17/include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/root/c_tests -ferror-limit 19 -fno-signed-char -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/main-9e40ef.o -x c main.c
clang -cc1 version 17.0.6 based upon LLVM 17.0.6 default target aarch64-unknown-freebsd15.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/clang/17/include
 /usr/include
End of search list.
 "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --enable-new-dtags -o a.out /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib -lsys /tmp/main-9e40ef.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o

# ldd -a a.out
a.out:
        libsys.so.7 => /lib/libsys.so.7 (0x19d023f23000)
        libc.so.7 => /lib/libc.so.7 (0x19d024622000)
/lib/libc.so.7:
        libsys.so.7 => /lib/libsys.so.7 (0x19d023f23000)




For reference for the pkgbase install (world ended up being
e53b83a849e3 based):

# uname -apKU
FreeBSD aarch64-main-pkgs 15.0-CURRENT FreeBSD 15.0-CURRENT main-n268410-445d3d227e68 GENERIC-NODEBUG arm64 aarch64 1500014 1500014

However, pkgbase does not have the kernel and world at the same place
relative to git commits of source code. See my note from yesterday:

https://lists.freebsd.org/archives/freebsd-pkgbase/2024-February/000319.html

Looking at /usr/src/tests/sys/kern/sigsys.c in this pkgbse context
shows the content from about 10 hours after 445d3d227e68's commit:

git: e53b83a849e3 - main - tests/sigsys: initialize parameter passed to sysctlbyname() Gleb Smirnoff
(CommitDate: 2024-02-20 22:37:45 +0000)

(Note: The next commit's source was not present.)


(As stands, finding what to report about the commits a pkgbase
installation is based on is a mess to deal with.)

===
Mark Millard
marklmi at yahoo.com