arm: Fix missing bti instruction for virtual thunks
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.
This commit is contained in:
parent
e5f50e63a8
commit
23f1b496aa
3 changed files with 24 additions and 0 deletions
|
@ -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
|
||||
|
|
20
gcc/testsuite/g++.target/arm/bti_thunk.C
Normal file
20
gcc/testsuite/g++.target/arm/bti_thunk.C
Normal file
|
@ -0,0 +1,20 @@
|
|||
/* { 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 } } */
|
|
@ -5533,6 +5533,8 @@ foreach { armfunc armflag armdefs } {
|
|||
__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 { } {
|
||||
|
|
Loading…
Add table
Reference in a new issue