diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index e5a944486d7bd583627b0e22dfe8f95862e975bb..91eee8be7c1a59118fbf443557561fb3e0689d61 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -29257,6 +29257,8 @@ arm_output_mi_thunk (FILE *file, tree thunk, HOST_WIDE_INT delta, 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 diff --git a/gcc/testsuite/g++.target/arm/bti_thunk.C b/gcc/testsuite/g++.target/arm/bti_thunk.C new file mode 100644 index 0000000000000000000000000000000000000000..5c4a8e5a8d74581eca2b877c000a5b34ddca0e9b --- /dev/null +++ b/gcc/testsuite/g++.target/arm/bti_thunk.C @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=armv8.1-m.main+pacbti -O1 -mbranch-protection=bti --save-temps" } */ + +#include + +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 } } */ \ No newline at end of file