Commit | Line | Data |
---|---|---|
7b6bb8da | 1 | # Copyright 2006, 2007, 2008, 2009, 2010, 2011 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 | ||
21 | if $tracelevel then { | |
22 | strace $tracelevel | |
23 | } | |
24 | ||
cc10cae3 | 25 | |
5e3b36f8 | 26 | if { ![isnative] || [is_remote host] || [skip_shlib_tests]} { |
cc10cae3 AO |
27 | return |
28 | } | |
29 | ||
30 | if [get_compiler_info "ignored"] { | |
31 | return -1 | |
32 | } | |
33 | ||
34 | if {$gcc_compiled == 0} { | |
35 | return -1 | |
36 | } | |
37 | ||
5e3b36f8 JK |
38 | load_lib prelink-support.exp |
39 | ||
cc10cae3 | 40 | set testfile "prelink" |
cc10cae3 AO |
41 | |
42 | set libsrcfile ${testfile}-lib.c | |
43 | set libfile ${objdir}/${subdir}/${testfile}.so | |
5e3b36f8 JK |
44 | |
45 | # Use -soname so that the new library gets copied by build_executable_own_libs. | |
46 | ||
d8b34041 | 47 | if { [gdb_compile_shlib "${srcdir}/${subdir}/${libsrcfile}" "${libfile}" [list debug "ldflags=-Wl,-soname,[file tail ${libfile}]"]] != ""} { |
cc10cae3 AO |
48 | # If creating the shared library fails, maybe we don't have the right tools |
49 | return -1 | |
50 | } | |
51 | ||
5e3b36f8 JK |
52 | set srcfile ${testfile}.c |
53 | set executable ${testfile}t | |
54 | set binfile ${objdir}/${subdir}/${executable} | |
d8b34041 | 55 | set prelink_args [build_executable_own_libs ${testfile}.exp $executable $srcfile [list debug "ldflags=-Wl,${libfile},-rpath,[file dirname ${libfile}]"]] |
5e3b36f8 | 56 | if {$prelink_args == ""} { |
cc10cae3 AO |
57 | return -1 |
58 | } | |
59 | ||
1276c759 JK |
60 | set test "split debug of executable" |
61 | if [gdb_gnu_strip_debug $binfile] { | |
62 | fail $test | |
63 | } else { | |
64 | pass $test | |
65 | } | |
66 | ||
5e3b36f8 JK |
67 | if ![prelink_yes $prelink_args] { |
68 | # Maybe we don't have prelink. | |
69 | return -1 | |
cc10cae3 AO |
70 | } |
71 | ||
72 | set found 0 | |
73 | set coredir "${objdir}/${subdir}/coredir.[getpid]" | |
74 | file mkdir $coredir | |
75 | catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\"" | |
76 | ||
77 | foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" { | |
78 | if [remote_file build exists $i] { | |
79 | remote_exec build "mv $i ${objdir}/${subdir}/prelink.core" | |
80 | set found 1 | |
81 | } | |
82 | } | |
83 | # Check for "core.PID". | |
84 | if { $found == 0 } { | |
85 | set names [glob -nocomplain -directory $coredir core.*] | |
86 | if {[llength $names] == 1} { | |
87 | set corefile [file join $coredir [lindex $names 0]] | |
88 | remote_exec build "mv $corefile ${objdir}/${subdir}/prelink.core" | |
89 | set found 1 | |
90 | } | |
91 | } | |
92 | ||
cc10cae3 AO |
93 | # Try to clean up after ourselves. |
94 | remote_file build delete [file join $coredir coremmap.data] | |
95 | remote_exec build "rmdir $coredir" | |
96 | ||
97 | if { $found == 0 } { | |
98 | warning "can't generate a core file - prelink tests suppressed - check ulimit -c" | |
99 | return 0 | |
100 | } | |
101 | ||
5e3b36f8 JK |
102 | # Relink $libfile to a different address. |
103 | if ![prelink_yes $prelink_args] { | |
104 | return -1 | |
5f4a23d9 | 105 | } |
5f4a23d9 | 106 | |
cc10cae3 AO |
107 | # Start with a fresh gdb |
108 | ||
5e3b36f8 | 109 | clean_restart $executable |
cc10cae3 | 110 | |
701ed6dc | 111 | # Print the "adjusting expectations" message. |
27d3a1a2 | 112 | gdb_test_no_output "set verbose on" |
701ed6dc | 113 | |
5e3b36f8 | 114 | gdb_test "core-file $objdir/$subdir/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 |
115 | |
116 | gdb_test "p &bssvar == bssvarp" " = 1" ".dynbss vs. .bss address shift" |