]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.arch/i386-prologue-skip-cf-protection.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / i386-prologue-skip-cf-protection.exp
CommitLineData
1d506c26 1# Copyright 2020-2024 Free Software Foundation, Inc.
ac4a4f1c
SM
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 skipping a prologue that was generated with gcc's -fcf-protection=full
17# (control flow protection) option.
18#
14f9473c
VC
19# This option places an `endbr32`/`endbr64` instruction at the start of
20# all functions, which can interfere with prologue analysis.
ac4a4f1c
SM
21
22standard_testfile .c
23set binfile ${binfile}
24
c7ccb471 25require {is_any_target x86_64-*-* i?86-*-*}
ac4a4f1c 26
73c06197 27require supports_fcf_protection
ac4a4f1c
SM
28
29set opts {debug additional_flags=-fcf-protection=full}
30
31if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $opts] != "" } {
32 untested "failed to compile"
33 return
34}
35
36clean_restart ${binfile}
37
38# Get start address of function main.
39set main_addr [get_integer_valueof &main -1]
40gdb_assert {$main_addr != -1}
41
42set bp_addr -1
43
44# Put breakpoint on main, get the address where the breakpoint was installed.
e777225b 45gdb_test_multiple "break -q main" "break on main, get address" {
ac4a4f1c
SM
46 -re -wrap "Breakpoint $decimal at ($hex).*" {
47 set bp_addr $expect_out(1,string)
48
49 # Convert to decimal.
50 set bp_addr [expr $bp_addr]
51
52 pass $gdb_test_name
53 }
54}
55
56if { $bp_addr != -1 } {
57 # Make sure some prologue was skipped.
58 gdb_assert {$bp_addr > $main_addr}
59}