Date: Sat, 11 Apr 2026 16:28:55 +0000 From: Xin LI <delphij@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Bjoern A. Zeeb <bz@freebsd.org> Subject: git: de2ea5423cc6 - main - zstd: disable weak-symbol tracing hooks in the kernel Message-ID: <69da76c7.24858.7f9be8f2@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=de2ea5423cc63b62e7e42d11b667aa634109fc28 commit de2ea5423cc63b62e7e42d11b667aa634109fc28 Author: Bjoern A. Zeeb <bz@freebsd.org> AuthorDate: 2026-04-11 16:24:32 +0000 Commit: Xin LI <delphij@FreeBSD.org> CommitDate: 2026-04-11 16:28:00 +0000 zstd: disable weak-symbol tracing hooks in the kernel zstd's tracing API (zstd_trace.h) declares ZSTD_trace_compress_begin() and friends as __attribute__((weak)) externals, gated on the ZSTD_HAVE_WEAK_SYMBOLS compile-time probe. That probe has covered x86_64 and i386 since at least zstd 1.5.6, and was extended to aarch64 and riscv in 1.5.7. In a static kernel image there is no dynamic linker to patch the PLT GOT entries at runtime. On amd64 the undefined weak symbols resolve directly to NULL, so the "!= NULL" guard in the zstd source correctly suppresses every call through the stubs. On aarch64 and riscv the ABI requires GOT-based indirection for external calls: the PLT stub address is non-NULL, the guard passes, and the call lands in an uninitialized GOT slot. Because this happens before exception handlers are in place the machine resets silently, making the kernel unbootable after the zstd 1.5.7 import. The upstream-supported suppression is ZSTD_NO_TRACE (zstd_internal.h), which skips inclusion of zstd_trace.h entirely and forces ZSTD_TRACE=0. Add it to ZSTD_C alongside the existing ZSTD_* defines, and while here group all three -DZSTD_* flags onto a single line in alphabetical order with ${.IMPSRC} on its own line. Reported by: many Tested by: lwhsu X-MFC-with: c0d9a07101a1 --- sys/conf/kern.pre.mk | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk index 871cd1c0705a..3dc1efe3d5d2 100644 --- a/sys/conf/kern.pre.mk +++ b/sys/conf/kern.pre.mk @@ -158,9 +158,11 @@ NORMAL_FWO= ${CC:N${CCACHE_BIN}} -c ${ASM_CFLAGS} ${WERROR} -o ${.TARGET} \ NOSAN_C= ${NORMAL_C:N-fsanitize*:N-fno-sanitize*:N-fasan-shadow-offset*} # for ZSTD in the kernel (include zstd/lib/freebsd before other CFLAGS) -ZSTD_C= ${CC} -c -DZSTD_HEAPMODE=1 -I$S/contrib/zstd/lib/freebsd ${CFLAGS} \ +ZSTD_C= ${CC} -c -I$S/contrib/zstd/lib/freebsd ${CFLAGS} \ -I$S/contrib/zstd/lib -I$S/contrib/zstd/lib/common ${WERROR} \ - -Wno-missing-prototypes -U__BMI__ -DZSTD_NO_INTRINSICS ${.IMPSRC} + -Wno-missing-prototypes -U__BMI__ \ + -DZSTD_HEAPMODE=1 -DZSTD_NO_INTRINSICS -DZSTD_NO_TRACE \ + ${.IMPSRC} # https://github.com/facebook/zstd/commit/812e8f2a [zstd 1.4.1] # "Note that [GCC] autovectorization still does not do a good job on the # optimized version, so it's turned off via attribute and flag. I foundhome | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69da76c7.24858.7f9be8f2>
