Adds missing bti instruction at the beginning of a virtual
thunk, when bti is enabled.
gcc/ChangeLog:
* config/arm/arm.cc (arm_output_mi_thunk): Emit
insn for bti_c when bti is enabled.
gcc/testsuite/ChangeLog:
* lib/target-supports.exp: Add v8_1_m_main_pacbti.
* g++.target/arm/bti_thunk.C: New test.
const char *fnname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (thunk));
assemble_start_function (thunk, fnname);
+ if (aarch_bti_enabled ())
+ emit_insn (aarch_gen_bti_c ());
if (TARGET_32BIT)
arm32_output_mi_thunk (file, thunk, delta, vcall_offset, function);
else
--- /dev/null
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_arch_v8_1m_main_pacbti_ok } */
+/* { dg-add-options arm_arch_v8_1m_main_pacbti } */
+/* { dg-additional-options "-mbranch-protection=bti" }*/
+
+#include <stdio.h>
+
+struct C18 {
+ virtual void f7();
+};
+
+struct C19 : virtual C18 {
+ virtual void f7();
+};
+
+void C19::f7() {
+ printf("foo\n");
+}
+
+/* { dg-final { scan-assembler-times "\tbti" 2 } } */
__ARM_ARCH_8M_BASE__
v8m_main "-march=armv8-m.main+fp -mthumb" __ARM_ARCH_8M_MAIN__
v8_1m_main "-march=armv8.1-m.main+fp -mthumb" __ARM_ARCH_8M_MAIN__
+ v8_1m_main_pacbti "-march=armv8.1-m.main+pacbti+fp -mthumb"
+ "__ARM_ARCH_8M_MAIN__ && __ARM_FEATURE_BTI"
v9a "-march=armv9-a+simd" __ARM_ARCH_9A__ } {
eval [string map [list FUNC $armfunc FLAG $armflag DEFS $armdefs ] {
proc check_effective_target_arm_arch_FUNC_ok { } {