On Ubuntu 22.04.1 x86_64, I run into:
...
gdb.reverse/step-indirect-call-thunk.c: In function 'inc':^M
gdb.reverse/step-indirect-call-thunk.c:22:1: error: '-mindirect-branch' and \
'-fcf-protection' are not compatible^M
22 | { /* inc.1 */^M
| ^^M
...
Fix this by forcing -fcf-protection=none, if supported.
Tested on x86_64-linux.
standard_testfile
-set cflags "-mindirect-branch=thunk -mfunction-return=thunk"
-if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
- [list debug "additional_flags=$cflags"]] } {
+set cflags {}
+lappend cflags debug
+lappend cflags additional_flags=-mindirect-branch=thunk
+lappend cflags additional_flags=-mfunction-return=thunk
+
+set fcf_protection_none additional_flags=-fcf-protection=none
+if { [gdb_can_simple_compile fcf-protection-none {int main () { return 0; }} \
+ executable $fcf_protection_none] } {
+ lappend cflags $fcf_protection_none
+}
+
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile $cflags] } {
return -1
}