[compiler-rt] 15711bd - [compiler-rt] Introduce asm macros for interceptor trampolines
Marco Elver via llvm-commits
llvm-commits at lists.llvm.org
Thu May 25 03:01:44 PDT 2023
Author: Marco Elver
Date: 2023-05-25T12:01:09+02:00
New Revision: 15711bd631894985c1342953747e77ffc091a4f3
URL: https://github.com/llvm/llvm-project/commit/15711bd631894985c1342953747e77ffc091a4f3
DIFF: https://github.com/llvm/llvm-project/commit/15711bd631894985c1342953747e77ffc091a4f3.diff
LOG: [compiler-rt] Introduce asm macros for interceptor trampolines
This introduces macros for asm sources to define trampolines, and
aliases to trampolines.
Because we currently do not yet have any real trampolines, this change
is a NFC.
Reviewed By: dvyukov, vitalybuka
Differential Revision: https://reviews.llvm.org/D151317
Added:
Modified:
compiler-rt/lib/hwasan/hwasan_setjmp_aarch64.S
compiler-rt/lib/hwasan/hwasan_setjmp_riscv64.S
compiler-rt/lib/hwasan/hwasan_setjmp_x86_64.S
compiler-rt/lib/sanitizer_common/sanitizer_asm.h
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_arm.inc.S
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_i386.inc.S
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_loongarch64.inc.S
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_riscv64.inc.S
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_x86_64.inc.S
Removed:
################################################################################
diff --git a/compiler-rt/lib/hwasan/hwasan_setjmp_aarch64.S b/compiler-rt/lib/hwasan/hwasan_setjmp_aarch64.S
index 25bd817ae862..1df2930565e1 100644
--- a/compiler-rt/lib/hwasan/hwasan_setjmp_aarch64.S
+++ b/compiler-rt/lib/hwasan/hwasan_setjmp_aarch64.S
@@ -53,6 +53,8 @@ ASM_WRAPPER_NAME(setjmp_bionic):
b ASM_WRAPPER_NAME(sigsetjmp)
CFI_ENDPROC
ASM_SIZE(ASM_WRAPPER_NAME(setjmp_bionic))
+
+ASM_INTERCEPTOR_TRAMPOLINE(setjmp_bionic)
#endif
.global ASM_WRAPPER_NAME(sigsetjmp)
@@ -79,20 +81,17 @@ ASM_WRAPPER_NAME(sigsetjmp):
CFI_ENDPROC
ASM_SIZE(ASM_WRAPPER_NAME(sigsetjmp))
+ASM_INTERCEPTOR_TRAMPOLINE(sigsetjmp)
-.macro WEAK_ALIAS first second
- .weak \second
- .equ \second\(), \first
-.endm
#if SANITIZER_ANDROID
-WEAK_ALIAS ASM_WRAPPER_NAME(sigsetjmp), sigsetjmp
-WEAK_ALIAS ASM_WRAPPER_NAME(setjmp_bionic), setjmp
+ASM_TRAMPOLINE_ALIAS(sigsetjmp, sigsetjmp)
+ASM_TRAMPOLINE_ALIAS(setjmp, setjmp_bionic)
#else
-WEAK_ALIAS ASM_WRAPPER_NAME(sigsetjmp), __sigsetjmp
+ASM_TRAMPOLINE_ALIAS(__sigsetjmp, sigsetjmp)
#endif
-WEAK_ALIAS ASM_WRAPPER_NAME(setjmp), _setjmp
+ASM_TRAMPOLINE_ALIAS(_setjmp, setjmp)
#endif
// We do not need executable stack.
diff --git a/compiler-rt/lib/hwasan/hwasan_setjmp_riscv64.S b/compiler-rt/lib/hwasan/hwasan_setjmp_riscv64.S
index 9a1a5f9ed2d2..c01f4e25e8a4 100644
--- a/compiler-rt/lib/hwasan/hwasan_setjmp_riscv64.S
+++ b/compiler-rt/lib/hwasan/hwasan_setjmp_riscv64.S
@@ -82,15 +82,10 @@ ASM_WRAPPER_NAME(sigsetjmp):
CFI_ENDPROC
ASM_SIZE(ASM_WRAPPER_NAME(sigsetjmp))
-
-.macro WEAK_ALIAS first second
- .weak \second
- .equ \second\(), \first
-.endm
-
-WEAK_ALIAS ASM_WRAPPER_NAME(sigsetjmp), __sigsetjmp
-
-WEAK_ALIAS ASM_WRAPPER_NAME(setjmp), _setjmp
+ASM_INTERCEPTOR_TRAMPOLINE(sigsetjmp)
+ASM_TRAMPOLINE_ALIAS(__sigsetjmp, sigsetjmp)
+ASM_INTERCEPTOR_TRAMPOLINE(setjmp)
+ASM_TRAMPOLINE_ALIAS(_setjmp, setjmp)
#endif
// We do not need executable stack.
diff --git a/compiler-rt/lib/hwasan/hwasan_setjmp_x86_64.S b/compiler-rt/lib/hwasan/hwasan_setjmp_x86_64.S
index b2c4c50f2fbc..9804e8d7ceca 100644
--- a/compiler-rt/lib/hwasan/hwasan_setjmp_x86_64.S
+++ b/compiler-rt/lib/hwasan/hwasan_setjmp_x86_64.S
@@ -69,14 +69,10 @@ ASM_WRAPPER_NAME(sigsetjmp):
CFI_ENDPROC
ASM_SIZE(ASM_WRAPPER_NAME(sigsetjmp))
-
-.macro WEAK_ALIAS first second
- .weak \second
- .equ \second\(), \first
-.endm
-
-WEAK_ALIAS ASM_WRAPPER_NAME(sigsetjmp), __sigsetjmp
-WEAK_ALIAS ASM_WRAPPER_NAME(setjmp), _setjmp
+ASM_INTERCEPTOR_TRAMPOLINE(sigsetjmp)
+ASM_TRAMPOLINE_ALIAS(__sigsetjmp, sigsetjmp)
+ASM_INTERCEPTOR_TRAMPOLINE(setjmp)
+ASM_TRAMPOLINE_ALIAS(_setjmp, setjmp)
#endif
// We do not need executable stack.
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_asm.h b/compiler-rt/lib/sanitizer_common/sanitizer_asm.h
index 9ebba91da73f..632c4bdd4c26 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_asm.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_asm.h
@@ -49,6 +49,10 @@
# define ASM_SYMBOL(symbol) symbol
# define ASM_SYMBOL_INTERCEPTOR(symbol) symbol
# define ASM_WRAPPER_NAME(symbol) __interceptor_##symbol
+# define ASM_TRAMPOLINE_ALIAS(symbol, name) \
+ .weak symbol; \
+ .set symbol, ASM_WRAPPER_NAME(name)
+# define ASM_INTERCEPTOR_TRAMPOLINE(name)
#else
# define ASM_HIDDEN(symbol)
# define ASM_TYPE_FUNCTION(symbol)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S
index 72e482754b62..cdfa6f1d7f53 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S
@@ -40,8 +40,8 @@ ASM_WRAPPER_NAME(vfork):
ret
ASM_SIZE(vfork)
-.weak vfork
-.set vfork, ASM_WRAPPER_NAME(vfork)
+ASM_INTERCEPTOR_TRAMPOLINE(vfork)
+ASM_TRAMPOLINE_ALIAS(vfork, vfork)
GNU_PROPERTY_BTI_PAC
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_arm.inc.S b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_arm.inc.S
index 780a9d46e26a..87bb48380569 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_arm.inc.S
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_arm.inc.S
@@ -43,7 +43,7 @@ ASM_WRAPPER_NAME(vfork):
ASM_SIZE(vfork)
-.weak vfork
-.set vfork, ASM_WRAPPER_NAME(vfork)
+ASM_INTERCEPTOR_TRAMPOLINE(vfork)
+ASM_TRAMPOLINE_ALIAS(vfork, vfork)
#endif
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_i386.inc.S b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_i386.inc.S
index f60b05d157bb..c633014e2daa 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_i386.inc.S
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_i386.inc.S
@@ -58,7 +58,7 @@ ASM_WRAPPER_NAME(vfork):
ret
ASM_SIZE(vfork)
-.weak vfork
-.set vfork, ASM_WRAPPER_NAME(vfork)
+ASM_INTERCEPTOR_TRAMPOLINE(vfork)
+ASM_TRAMPOLINE_ALIAS(vfork, vfork)
#endif
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_loongarch64.inc.S b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_loongarch64.inc.S
index 68782acb379d..8429d57d669c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_loongarch64.inc.S
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_loongarch64.inc.S
@@ -51,7 +51,7 @@ ASM_WRAPPER_NAME(vfork):
jr $ra
ASM_SIZE(vfork)
-.weak vfork
-.set vfork, ASM_WRAPPER_NAME(vfork)
+ASM_INTERCEPTOR_TRAMPOLINE(vfork)
+ASM_TRAMPOLINE_ALIAS(vfork, vfork)
#endif
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_riscv64.inc.S b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_riscv64.inc.S
index b7ec27859b8a..5b6ea6fe6c7a 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_riscv64.inc.S
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_riscv64.inc.S
@@ -50,7 +50,7 @@ ASM_WRAPPER_NAME(vfork):
ret
ASM_SIZE(vfork)
-.weak vfork
-.set vfork, ASM_WRAPPER_NAME(vfork)
+ASM_INTERCEPTOR_TRAMPOLINE(vfork)
+ASM_TRAMPOLINE_ALIAS(vfork, vfork)
#endif
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_x86_64.inc.S b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_x86_64.inc.S
index 8fd18ea67ffd..5500f817aec5 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_x86_64.inc.S
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_x86_64.inc.S
@@ -34,9 +34,9 @@ ASM_WRAPPER_NAME(vfork):
.L_exit:
pop %rax
ret
-ASM_SIZE(vfork)
+ASM_SIZE(ASM_WRAPPER_NAME(vfork))
-.weak vfork
-.set vfork, ASM_WRAPPER_NAME(vfork)
+ASM_INTERCEPTOR_TRAMPOLINE(vfork)
+ASM_TRAMPOLINE_ALIAS(vfork, vfork)
#endif
More information about the llvm-commits
mailing list