Skip to content

Commit

Permalink
[compiler-rt] Use .globl for FreeBSD/NetBSD interceptor wrappers
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jrtc27 authored and razmser committed Oct 6, 2023
1 parent ec8720d commit 49df340
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compiler-rt/lib/interception/interception.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ const interpose_substitution substitution_##func_name[] \
// FreeBSD's dynamic linker (incompliantly) gives non-weak symbols higher
// priority than weak ones so weak aliases won't work for indirect calls
// in position-independent (-fPIC / -fPIE) mode.
# define __ASM_WEAK_WRAPPER(func)
# define __ASM_WEAK_WRAPPER(func) ".globl " #func "\n"
# else
# define __ASM_WEAK_WRAPPER(func) ".weak " #func "\n"
# endif // SANITIZER_FREEBSD || SANITIZER_NETBSD
Expand Down

0 comments on commit 49df340

Please sign in to comment.