Skip to content

Commit 7e1afab

Browse files
committed
[compiler-rt] Use .globl for FreeBSD/NetBSD interceptor wrappers
On FreeBSD and NetBSD we don't use .weak due to differing semantics. Currently we end up using no directive, which gives a local symbol, whereas the closer thing to a weak symbol would be a global one. In particular, both GNU and LLVM toolchains cannot handle a GOT-indirect reference to a local symbol at a non-zero offset within a section on AArch64 (see ARM-software/abi-aa#217), and so interceptors do not work on FreeBSD/arm64, failing to link with LLD. Switching to .globl both works around this bug and more closely aligns such non-weak platforms with weak ones. Fixes llvm#63418 Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D158552
1 parent 7dc5bde commit 7e1afab

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compiler-rt/lib/interception/interception.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ const interpose_substitution substitution_##func_name[] \
181181
// FreeBSD's dynamic linker (incompliantly) gives non-weak symbols higher
182182
// priority than weak ones so weak aliases won't work for indirect calls
183183
// in position-independent (-fPIC / -fPIE) mode.
184-
# define __ASM_WEAK_WRAPPER(func)
184+
# define __ASM_WEAK_WRAPPER(func) ".globl " #func "\n"
185185
# else
186186
# define __ASM_WEAK_WRAPPER(func) ".weak " #func "\n"
187187
# endif // SANITIZER_FREEBSD || SANITIZER_NETBSD

0 commit comments

Comments
 (0)