3f42cb4fe670812692df205b012372f5ecd6271d
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / gcore-tls-pie.exp
1 # Copyright 2013-2021 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 # PR 11786 (Gold and strip differ on memsz field of PT_TLS).
17 # Generate a core file from the stripped version of the program,
18 # and then try to debug the core with the unstripped version.
19
20 standard_testfile
21
22 if { [have_fuse_ld_gold] == 0} {
23 return -1
24 }
25
26 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug additional_flags=-fpie "ldflags=-pie -fuse-ld=gold"}]} {
27 return -1
28 }
29
30 set stripped_binfile ${binfile}.stripped
31 set gcorefile ${binfile}.gcore
32
33 set strip_program [transform strip]
34 remote_file host delete ${stripped_binfile}
35 if [run_on_host "strip" "$strip_program" "-g -o ${stripped_binfile} $binfile"] {
36 return -1
37 }
38
39 # Workaround PR binutils/10802:
40 # Preserve the 'x' bit also for PIEs (Position Independent Executables).
41 set perm [file attributes ${binfile} -permissions]
42 file attributes ${stripped_binfile} -permissions $perm
43
44 clean_restart ${stripped_binfile}
45
46 # The binary is stripped of debug info, but not minsyms.
47 if ![runto break_here] {
48 fail "can't run to break_here"
49 return -1
50 }
51
52 if {![gdb_gcore_cmd $gcorefile "save a corefile"]} {
53 return -1
54 }
55
56 # Now restart gdb with the unstripped binary and load the corefile.
57
58 clean_restart ${binfile}
59
60 gdb_test "core ${gcorefile}" \
61 "Core was generated by .*" "re-load generated corefile"
62
63 # Put $pc in gdb.log for debug purposes for comparison with stripped case.
64 gdb_test "x/i \$pc" "break_here.*"
65
66 gdb_test "frame" "#0 \[^\r\n\]* break_here .*" "unstripped + core ok"
This page took 0.040501 seconds and 3 git commands to generate.