]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.arch/aarch64-pauth.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / aarch64-pauth.exp
1 # Copyright (C) 2019-2024 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 # Test a binary with address signing works regardless of whether the target
17 # supports pauth instructions. On non pauth systems, all pauth instructions
18 # are treated as nops.
19
20 require is_aarch64_target
21
22 require {have_compile_flag -mbranch-protection=pac-ret+leaf}
23
24 # Build program with address signing forced on.
25 standard_testfile
26 set compile_flags {debug}
27 lappend compile_flags "additional_flags=-fno-inline"
28
29 # Records whether the compilation was successful or not.
30 set compilation_ok 0
31
32 # We need to try a couple compilation flags here because -msign-return-address
33 # was dropped at some point, but could still be supported.
34 foreach pauth_flag "-mbranch-protection=pac-ret+leaf -msign-return-address=all" {
35 set flags $compile_flags
36 lappend flags "additional_flags=$pauth_flag"
37
38 if {!$compilation_ok && ![prepare_for_testing "failed to prepare" ${testfile} ${srcfile} ${flags}] } {
39 set compilation_ok 1
40 }
41 }
42
43 # If we couldn't compile, just bail out.
44 if {!$compilation_ok} {
45 return -1
46 }
47
48 if ![runto_main] {
49 return -1
50 }
51
52 gdb_breakpoint [ gdb_get_line_number "break here" ]
53 gdb_continue_to_breakpoint "break here" ".*break here.*"
54
55 # Ensure we can get a full backtrace, despite the address signing.
56 gdb_test "bt" \
57 [multi_line \
58 "#0\[ \t\]+bar \\(b=9\\) at \[^\r\n\]+" \
59 "#1\[ \t\]+$hex (\\\[PAC\\\] )?in foo \\(a=5\\) at \[^\r\n\]+" \
60 "#2\[ \t\]+$hex (\\\[PAC\\\] )?in main \\(\\) at \[^\r\n\]+" ] \
61 "backtrace"