Switch the license of all .exp files to GPLv3.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / prelink.exp
CommitLineData
6aba47ca 1# Copyright 2006, 2007 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
21if $tracelevel then {
22 strace $tracelevel
23 }
24
25set prms_id 0
26set bug_id 0
27
28# are we on a target board
29if ![isnative] then {
30 return
31}
32
33if [get_compiler_info "ignored"] {
34 return -1
35}
36
37if {$gcc_compiled == 0} {
38 return -1
39}
40
41set testfile "prelink"
cc10cae3
AO
42
43set libsrcfile ${testfile}-lib.c
44set libfile ${objdir}/${subdir}/${testfile}.so
45if { [gdb_compile "${srcdir}/${subdir}/${libsrcfile}" "${libfile}" executable [list debug "additional_flags=-fpic -shared -nodefaultlibs"]] != ""} {
46 # If creating the shared library fails, maybe we don't have the right tools
47 return -1
48}
49
5f4a23d9 50if {[catch "system \"prelink -qNR ${libfile}\""] != 0} {
cc10cae3
AO
51 # Maybe we don't have prelink.
52 return -1
53}
54
55set srcfile ${testfile}.c
5f4a23d9 56set binfile ${objdir}/${subdir}/${testfile}t
cc10cae3
AO
57if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${libfile}" "${binfile}" executable [list debug "additional_flags=-Wl,-rpath,${objdir}/${subdir}"]] != ""} {
58 return -1;
59}
60
61set found 0
62set coredir "${objdir}/${subdir}/coredir.[getpid]"
63file mkdir $coredir
64catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\""
65
66foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" {
67 if [remote_file build exists $i] {
68 remote_exec build "mv $i ${objdir}/${subdir}/prelink.core"
69 set found 1
70 }
71}
72# Check for "core.PID".
73if { $found == 0 } {
74 set names [glob -nocomplain -directory $coredir core.*]
75 if {[llength $names] == 1} {
76 set corefile [file join $coredir [lindex $names 0]]
77 remote_exec build "mv $corefile ${objdir}/${subdir}/prelink.core"
78 set found 1
79 }
80}
81
cc10cae3
AO
82# Try to clean up after ourselves.
83remote_file build delete [file join $coredir coremmap.data]
84remote_exec build "rmdir $coredir"
85
86if { $found == 0 } {
87 warning "can't generate a core file - prelink tests suppressed - check ulimit -c"
88 return 0
89}
90
5f4a23d9 91if {[catch "system \"prelink -uN ${libfile}\""] != 0} {
c499ed39 92 untested "${testfile}.so was not prelinked, maybe system libraries are not prelinked?"
5f4a23d9
AO
93 return 0
94}
95catch "system \"prelink -qNR ${libfile}\""
96
cc10cae3
AO
97# Start with a fresh gdb
98
99gdb_exit
100gdb_start
101gdb_reinitialize_dir $srcdir/$subdir
102gdb_load ${binfile}
103
5f4a23d9 104set test "prelink"
831004b7 105global gdb_prompt
5f4a23d9 106gdb_test_multiple "core-file $objdir/$subdir/prelink.core" "$test" {
831004b7 107 -re "warning: \.dynamic section.*not at the expected address.*warning: difference.*caused by prelink, adjusting expectations.*$gdb_prompt $" {
5f4a23d9 108 pass "$test"
cc10cae3 109 }
cc10cae3 110}
cc10cae3
AO
111
112gdb_exit
113
114return 0
115
This page took 0.141358 seconds and 4 git commands to generate.