]>
Commit | Line | Data |
---|---|---|
213516ef | 1 | # Copyright 2006-2023 Free Software Foundation, Inc. |
cc10cae3 AO |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
cc10cae3 AO |
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 | |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
cc10cae3 AO |
15 | |
16 | # Please email any bugs, comments, and/or additions to this file to: | |
5f4a23d9 | 17 | # bug-gdb@gnu.org |
cc10cae3 AO |
18 | |
19 | # This file was written by Alexandre Oliva <aoliva@redhat.com> | |
20 | ||
cc10cae3 | 21 | |
5e3b36f8 | 22 | if { ![isnative] || [is_remote host] || [skip_shlib_tests]} { |
cc10cae3 AO |
23 | return |
24 | } | |
25 | ||
ef7a6b97 AB |
26 | if {![is_c_compiler_gcc]} { |
27 | unsupported "gcc compiler is required" | |
cc10cae3 AO |
28 | return -1 |
29 | } | |
30 | ||
5e3b36f8 JK |
31 | load_lib prelink-support.exp |
32 | ||
cc10cae3 | 33 | set testfile "prelink" |
cc10cae3 AO |
34 | |
35 | set libsrcfile ${testfile}-lib.c | |
08b3fe69 | 36 | set libfile [standard_output_file ${testfile}.so] |
5e3b36f8 JK |
37 | |
38 | # Use -soname so that the new library gets copied by build_executable_own_libs. | |
39 | ||
d8b34041 | 40 | if { [gdb_compile_shlib "${srcdir}/${subdir}/${libsrcfile}" "${libfile}" [list debug "ldflags=-Wl,-soname,[file tail ${libfile}]"]] != ""} { |
cc10cae3 AO |
41 | # If creating the shared library fails, maybe we don't have the right tools |
42 | return -1 | |
43 | } | |
44 | ||
5e3b36f8 JK |
45 | set srcfile ${testfile}.c |
46 | set executable ${testfile}t | |
08b3fe69 | 47 | set binfile [standard_output_file ${executable}] |
d8b34041 | 48 | set prelink_args [build_executable_own_libs ${testfile}.exp $executable $srcfile [list debug "ldflags=-Wl,${libfile},-rpath,[file dirname ${libfile}]"]] |
5e3b36f8 | 49 | if {$prelink_args == ""} { |
cc10cae3 AO |
50 | return -1 |
51 | } | |
52 | ||
1276c759 JK |
53 | set test "split debug of executable" |
54 | if [gdb_gnu_strip_debug $binfile] { | |
55 | fail $test | |
56 | } else { | |
57 | pass $test | |
58 | } | |
59 | ||
5e3b36f8 JK |
60 | if ![prelink_yes $prelink_args] { |
61 | # Maybe we don't have prelink. | |
62 | return -1 | |
cc10cae3 AO |
63 | } |
64 | ||
65 | set found 0 | |
08b3fe69 | 66 | set coredir "[standard_output_file coredir.[getpid]]" |
cc10cae3 AO |
67 | file mkdir $coredir |
68 | catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\"" | |
69 | ||
70 | foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" { | |
71 | if [remote_file build exists $i] { | |
08b3fe69 | 72 | remote_exec build "mv $i [standard_output_file prelink.core]" |
cc10cae3 AO |
73 | set found 1 |
74 | } | |
75 | } | |
76 | # Check for "core.PID". | |
77 | if { $found == 0 } { | |
78 | set names [glob -nocomplain -directory $coredir core.*] | |
79 | if {[llength $names] == 1} { | |
80 | set corefile [file join $coredir [lindex $names 0]] | |
08b3fe69 | 81 | remote_exec build "mv $corefile [standard_output_file prelink.core]" |
cc10cae3 AO |
82 | set found 1 |
83 | } | |
84 | } | |
85 | ||
cc10cae3 AO |
86 | # Try to clean up after ourselves. |
87 | remote_file build delete [file join $coredir coremmap.data] | |
88 | remote_exec build "rmdir $coredir" | |
89 | ||
90 | if { $found == 0 } { | |
91 | warning "can't generate a core file - prelink tests suppressed - check ulimit -c" | |
92 | return 0 | |
93 | } | |
94 | ||
5e3b36f8 JK |
95 | # Relink $libfile to a different address. |
96 | if ![prelink_yes $prelink_args] { | |
97 | return -1 | |
5f4a23d9 | 98 | } |
5f4a23d9 | 99 | |
cc10cae3 AO |
100 | # Start with a fresh gdb |
101 | ||
5e3b36f8 | 102 | clean_restart $executable |
cc10cae3 | 103 | |
701ed6dc | 104 | # Print the "adjusting expectations" message. |
27d3a1a2 | 105 | gdb_test_no_output "set verbose on" |
701ed6dc | 106 | |
08b3fe69 | 107 | 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" |
1276c759 JK |
108 | |
109 | gdb_test "p &bssvar == bssvarp" " = 1" ".dynbss vs. .bss address shift" |