]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/prelink.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / prelink.exp
1 # Copyright 2006-2024 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 # Please email any bugs, comments, and/or additions to this file to:
17 # bug-gdb@gnu.org
18
19 # This file was written by Alexandre Oliva <aoliva@redhat.com>
20
21
22 require isnative allow_shlib_tests is_c_compiler_gcc
23 require {!is_remote host}
24
25 load_lib prelink-support.exp
26
27 set testfile "prelink"
28
29 set libsrcfile ${testfile}-lib.c
30 set libfile [standard_output_file ${testfile}.so]
31
32 # Use -soname so that the new library gets copied by build_executable_own_libs.
33
34 if { [gdb_compile_shlib "${srcdir}/${subdir}/${libsrcfile}" "${libfile}" [list debug "ldflags=-Wl,-soname,[file tail ${libfile}]"]] != ""} {
35 # If creating the shared library fails, maybe we don't have the right tools
36 return -1
37 }
38
39 set srcfile ${testfile}.c
40 set executable ${testfile}t
41 set binfile [standard_output_file ${executable}]
42 set prelink_args [build_executable_own_libs ${testfile}.exp $executable $srcfile [list debug "ldflags=-Wl,${libfile},-rpath,[file dirname ${libfile}]"]]
43 if {$prelink_args == ""} {
44 return -1
45 }
46
47 set test "split debug of executable"
48 if [gdb_gnu_strip_debug $binfile] {
49 fail $test
50 } else {
51 pass $test
52 }
53
54 if ![prelink_yes $prelink_args] {
55 # Maybe we don't have prelink.
56 return -1
57 }
58
59 set found 0
60 set coredir "[standard_output_file coredir.[getpid]]"
61 file mkdir $coredir
62 catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\""
63
64 foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" {
65 if [remote_file build exists $i] {
66 remote_exec build "mv $i [standard_output_file prelink.core]"
67 set found 1
68 }
69 }
70 # Check for "core.PID".
71 if { $found == 0 } {
72 set names [glob -nocomplain -directory $coredir core.*]
73 if {[llength $names] == 1} {
74 set corefile [file join $coredir [lindex $names 0]]
75 remote_exec build "mv $corefile [standard_output_file prelink.core]"
76 set found 1
77 }
78 }
79
80 # Try to clean up after ourselves.
81 remote_file build delete [file join $coredir coremmap.data]
82 remote_exec build "rmdir $coredir"
83
84 if { $found == 0 } {
85 warning "can't generate a core file - prelink tests suppressed - check ulimit -c"
86 return 0
87 }
88
89 # Relink $libfile to a different address.
90 if ![prelink_yes $prelink_args] {
91 return -1
92 }
93
94 # Start with a fresh gdb
95
96 clean_restart $executable
97
98 # Print the "adjusting expectations" message.
99 gdb_test_no_output "set verbose on"
100
101 gdb_test "core-file [standard_output_file prelink.core]" "Using PIC \\(Position Independent Code\\) prelink displacement 0x\[^0\]\[0-9a-f\]* for \[^\r\n\]*[file tail ${libfile}].*" "seen displacement message"
102
103 gdb_test "p &bssvar == bssvarp" " = 1" ".dynbss vs. .bss address shift"