Commit | Line | Data |
---|---|---|
3666a048 | 1 | # Copyright 2012-2021 Free Software Foundation, Inc. |
4f69f4c2 JK |
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 | if {[skip_shlib_tests]} { | |
17 | return 0 | |
18 | } | |
19 | ||
20 | standard_testfile gcore-relro-main.c | |
21 | set libfile gcore-relro-lib | |
22 | set srcfile_lib ${libfile}.c | |
23 | set binfile_lib [standard_output_file ${libfile}.so] | |
24 | set gcorefile ${binfile}.gcore | |
25 | set objfile [standard_output_file ${testfile}.o] | |
26 | ||
27 | if { [gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} {debug}] != "" | |
28 | || [gdb_compile ${srcdir}/${subdir}/${srcfile} ${objfile} object {debug}] != "" } { | |
5b362f04 | 29 | untested "failed to compile" |
4f69f4c2 JK |
30 | return -1 |
31 | } | |
32 | set opts [list debug shlib=${binfile_lib} additional_flags=-Wl,-z,relro] | |
33 | if { [gdb_compile ${objfile} ${binfile} executable $opts] != "" } { | |
34 | unsupported "-Wl,-z,relro compilation failed" | |
35 | return -1 | |
36 | } | |
37 | ||
38 | clean_restart ${binfile} | |
d9019901 | 39 | gdb_load_shlib ${binfile_lib} |
4f69f4c2 | 40 | |
4f69f4c2 JK |
41 | if ![runto lib] { |
42 | return -1 | |
43 | } | |
44 | ||
2d338fa9 TT |
45 | if {![gdb_gcore_cmd $gcorefile "save a corefile"]} { |
46 | return -1 | |
4f69f4c2 JK |
47 | } |
48 | ||
49 | # Now restart gdb and load the corefile. | |
50 | ||
51 | clean_restart ${binfile} | |
d9019901 | 52 | gdb_load_shlib ${binfile_lib} |
4f69f4c2 JK |
53 | |
54 | gdb_test "core ${gcorefile}" "Core was generated by .*" "re-load generated corefile" | |
55 | ||
56 | gdb_test "frame" "#0 \[^\r\n\]* lib .*" "library got loaded" |