[llvm-branch-commits] [compiler-rt] c6d6417 - [compiler-rt] Use .globl for FreeBSD/NetBSD interceptor wrappers

Tobias Hieta via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Aug 25 00:37:06 PDT 2023


Author: Jessica Clarke
Date: 2023-08-25T09:27:09+02:00
New Revision: c6d6417a0b7cd3a855ae8dcc6dd1111e1759dd2a

URL: https://github.com/llvm/llvm-project/commit/c6d6417a0b7cd3a855ae8dcc6dd1111e1759dd2a
DIFF: https://github.com/llvm/llvm-project/commit/c6d6417a0b7cd3a855ae8dcc6dd1111e1759dd2a.diff

LOG: [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 https://github.com/ARM-software/abi-aa/issues/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 https://github.com/llvm/llvm-project/issues/63418

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D158552

(cherry picked from commit 7e1afab1b1821550c5f8d0d6a50636236fa02e2c)

Added: 
    

Modified: 
    compiler-rt/lib/interception/interception.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/interception/interception.h b/compiler-rt/lib/interception/interception.h
index 078d33b61be318..069f73d276f3c4 100644
--- a/compiler-rt/lib/interception/interception.h
+++ b/compiler-rt/lib/interception/interception.h
@@ -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


        


More information about the llvm-branch-commits mailing list