]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/testsuite/ld-x86-64/mpx.exp
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-x86-64 / mpx.exp
1 # Expect script for ELF MPX tests.
2 # Copyright (C) 2013-2021 Free Software Foundation, Inc.
3 #
4 # This file is part of the GNU Binutils.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 # MA 02110-1301, USA.
20 #
21
22 # The following tests require running the executable generated by ld,
23 # or enough of a build environment to create a fully linked executable.
24 # This is not commonly available when testing a cross-built linker.
25 if ![isnative] {
26 return
27 }
28
29 # Only on Linux for now.
30 if ![istarget "x86_64-*-linux*"] {
31 return
32 }
33
34 # Check to see if the C compiler works
35 if { ![check_compiler_available] } {
36 return
37 }
38
39 run_cc_link_tests [list \
40 [list \
41 "Build libmpx1a.a" \
42 "" \
43 "-Wa,-madd-bnd-prefix -fPIC $PLT_CFLAGS" \
44 {mpx1a.c} \
45 {{readelf {-r --wide} mpx1a.rd}} \
46 "libmpx1a.a" \
47 ] \
48 [list \
49 "Build libmpx1b.a" \
50 "" \
51 "" \
52 {mpx1b.c} \
53 {} \
54 "libmpx1b.a" \
55 ] \
56 [list \
57 "Build libmpx1c.a" \
58 "" \
59 "-Wa,-madd-bnd-prefix" \
60 {mpx1c.c} \
61 {{readelf {-r --wide} mpx1c.rd}} \
62 "libmpx1c.a" \
63 ] \
64 [list \
65 "Build libmpx2a.a" \
66 "" \
67 "-Wa,-madd-bnd-prefix -fPIE $PLT_CFLAGS" \
68 {mpx2a.c} \
69 {{readelf {-r --wide} mpx2a.rd}} \
70 "libmpx2a.a" \
71 ] \
72 [list \
73 "Build libmpx2b.a" \
74 "" \
75 "-fPIE" \
76 {mpx2b.c} \
77 {} \
78 "libmpx2b.a" \
79 ] \
80 [list \
81 "Build libmpx2c.a" \
82 "" \
83 "-Wa,-madd-bnd-prefix -fPIE $PLT_CFLAGS" \
84 {mpx2c.c} \
85 {{readelf {-r --wide} mpx2c.rd}} \
86 "libmpx2c.a" \
87 ] \
88 ]
89
90 set run_tests {
91 {"Run mpx1"
92 "tmpdir/mpx1a.o tmpdir/mpx1b.o tmpdir/mpx1c.o" ""
93 {dummy.s} "mpx1" "mpx1.out"}
94 {"Run mpx1 with -static"
95 "tmpdir/mpx1a.o tmpdir/mpx1b.o tmpdir/mpx1c.o -static" ""
96 {dummy.s} "mpx1static" "mpx1.out"}
97 {"Run mpx2"
98 "tmpdir/mpx2a.o tmpdir/mpx2b.o tmpdir/mpx2c.o -pie" ""
99 {dummy.s} "mpx2" "mpx2.out"}
100 {"Run mpx2 with -static"
101 "tmpdir/mpx2a.o tmpdir/mpx2b.o tmpdir/mpx2c.o -static" ""
102 {dummy.s} "mpx2static" "mpx2.out"}
103 }
104
105 run_ld_link_tests {
106 {"Build libcall.so"
107 "-m elf_x86_64 -shared -z bndplt" ""
108 "--64" {mpx3b.s} {} "libcall.so"}
109 {"Build mpx3"
110 "-m elf_x86_64 -z bndplt tmpdir/libcall.so" ""
111 "--64" {mpx3a.s} {{objdump -dw mpx3.dd}} "mpx3"}
112 {"Build libcall1.so"
113 "-m elf_x86_64 -shared -z bndplt" ""
114 "--64" {mpx4b.s} {} "libcall1.so"}
115 {"Build mpx4"
116 "-m elf_x86_64 -z bndplt --hash-style=sysv tmpdir/libcall1.so \
117 -z max-page-size=0x200000 -z noseparate-code" ""
118 "--64 -mx86-used-note=no" {mpx4a.s} {{objdump -dw mpx4.dd}} "mpx4"}
119 {"Build mpx3 (-z now)"
120 "-z now -m elf_x86_64 -z bndplt --hash-style=sysv tmpdir/libcall.so \
121 -z max-page-size=0x200000 -z noseparate-code" ""
122 "--64 -mx86-used-note=no" {mpx3a.s} {{objdump -dw mpx3n.dd}} "mpx3n"}
123 {"Build mpx4 (-z now)"
124 "-z now -m elf_x86_64 -z bndplt --hash-style=sysv tmpdir/libcall1.so \
125 -z max-page-size=0x200000 -z noseparate-code" ""
126 "--64 -mx86-used-note=no" {mpx4a.s} {{objdump -dw mpx4n.dd}} "mpx4n"}
127 }
128
129 run_ld_link_exec_tests $run_tests
130
131 run_dump_test "bnd-branch-1"
132 run_dump_test "bnd-ifunc-1"
133 run_dump_test "bnd-ifunc-2"
134 run_dump_test "bnd-plt-1"
135 run_dump_test "bnd-branch-1-now"
136 run_dump_test "bnd-ifunc-1-now"
137 run_dump_test "bnd-ifunc-2-now"
138 run_dump_test "bnd-plt-1-now"