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