Skip to content

Commit a855a16

Browse files
authored
[compiler-rt] Fix interceptors with Solaris as (#72973)
Jakub Jelínek reports: As mentioned in https://gcc.gnu.org/PR112563, the new DECLARE_WRAPPER macro added in 37445e9 and ammended in 85d3873 doesn't work on SPARC/Solaris with Solaris as. While clang and GNU as when used from GCC seems to be forgiving on most architectures and allow both %function and @function (with the latter not being allowed on ARM/AArch64 I believe because @ is assembler comment start there), Solaris as doesn't allow the %function form. Fix it by using %function only for ARM. Co-developed-by: Jakub Jelínek <[email protected]> Reported-by: Jakub Jelínek <[email protected]> Closes: #72970
1 parent 46a8479 commit a855a16

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

compiler-rt/lib/interception/interception.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ const interpose_substitution substitution_##func_name[] \
185185
# else
186186
# define __ASM_WEAK_WRAPPER(func) ".weak " #func "\n"
187187
# endif // SANITIZER_FREEBSD || SANITIZER_NETBSD
188+
# if defined(__arm__) || defined(__aarch64__)
189+
# define ASM_TYPE_FUNCTION_STR "%function"
190+
# else
191+
# define ASM_TYPE_FUNCTION_STR "@function"
192+
# endif
188193
// Keep trampoline implementation in sync with sanitizer_common/sanitizer_asm.h
189194
# define DECLARE_WRAPPER(ret_type, func, ...) \
190195
extern "C" ret_type func(__VA_ARGS__); \
@@ -196,7 +201,8 @@ const interpose_substitution substitution_##func_name[] \
196201
__ASM_WEAK_WRAPPER(func) \
197202
".set " #func ", " SANITIZER_STRINGIFY(TRAMPOLINE(func)) "\n" \
198203
".globl " SANITIZER_STRINGIFY(TRAMPOLINE(func)) "\n" \
199-
".type " SANITIZER_STRINGIFY(TRAMPOLINE(func)) ", %function\n" \
204+
".type " SANITIZER_STRINGIFY(TRAMPOLINE(func)) ", " \
205+
ASM_TYPE_FUNCTION_STR "\n" \
200206
SANITIZER_STRINGIFY(TRAMPOLINE(func)) ":\n" \
201207
SANITIZER_STRINGIFY(CFI_STARTPROC) "\n" \
202208
SANITIZER_STRINGIFY(ASM_TAIL_CALL) " __interceptor_" \

compiler-rt/lib/sanitizer_common/sanitizer_asm.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@
6262

6363
#if !defined(__APPLE__)
6464
# define ASM_HIDDEN(symbol) .hidden symbol
65-
# define ASM_TYPE_FUNCTION(symbol) .type symbol, %function
65+
# if defined(__arm__) || defined(__aarch64__)
66+
# define ASM_TYPE_FUNCTION(symbol) .type symbol, %function
67+
# else
68+
# define ASM_TYPE_FUNCTION(symbol) .type symbol, @function
69+
# endif
6670
# define ASM_SIZE(symbol) .size symbol, .-symbol
6771
# define ASM_SYMBOL(symbol) symbol
6872
# define ASM_SYMBOL_INTERCEPTOR(symbol) symbol

0 commit comments

Comments
 (0)