Skip to content

Commit 270750f

Browse files
committed
CONC-774 fixup: Always emit BTI J
In commit e2e5113 an incorrect numeric encoding was added that is for the instruction BTI, not BTI J. According to https://www.spinics.net/lists/arm-kernel/msg1041915.html the two most significant bits of the least significant octet of the instruction word for BTI are [J][C] flags. Because a newer version of GCC could emit code for an older assembler, we had better always use the numeric encoding on GCC. In clang and derivatives, the assembler is built-in.
1 parent c80f221 commit 270750f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

libmariadb/ma_context.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -638,11 +638,19 @@ my_context_destroy(struct my_context *c)
638638

639639
#ifdef MY_CONTEXT_USE_AARCH64_GCC_ASM
640640

641-
#if (defined(__clang__) && (__clang_major__ >= 9)) || \
642-
(defined(__GNUC__) && (__GNUC__ > 9 || (__GNUC__ == 9 && __GNUC_MINOR__ >= 1)))
643-
#define BTI_J_STR "bti j"
641+
/* According to ARM, the instruction BTI [J][C] is a NOP in ARMv8
642+
implementations that do not support it. However, the built-in assembler
643+
in clang 9 through 11 would refuse to emit the instruction unless a
644+
late enough ARMv8.x-A is specified.
645+
646+
On GCC, we cannot easily detect which assembler is going to be invoked
647+
to translate the symbolic assembler code to binary. Hence, we will always
648+
use the numeric encoding in order to be compatible with old assemblers. */
649+
650+
#if defined __clang_major__ && __clang_major__ >= 12
651+
# define BTI_J_STR "bti j"
644652
#else
645-
#define BTI_J_STR ".inst 0xd503241f"
653+
# define BTI_J_STR ".inst 0xd503249f"
646654
#endif
647655
/*
648656
GCC-aarch64 (arm64) implementation of my_context.

0 commit comments

Comments
 (0)