1 # Copyright 2006 Free Software Foundation, Inc.
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 2 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 # Please email any bugs, comments, and/or additions to this file to:
20 # This file was written by Alexandre Oliva <aoliva@redhat.com>
29 # are we on a target board
34 if [get_compiler_info "ignored"] {
38 if {$gcc_compiled == 0} {
42 set testfile "prelink"
44 set libsrcfile ${testfile}-lib.c
45 set libfile ${objdir}/${subdir}/${testfile}.so
46 if { [gdb_compile "${srcdir}/${subdir}/${libsrcfile}" "${libfile}" executable [list debug "additional_flags=-fpic -shared -nodefaultlibs"]] != ""} {
47 # If creating the shared library fails, maybe we don't have the right tools
51 if {[catch "system \"prelink -qNR ${libfile}\""] != 0} {
52 # Maybe we don't have prelink.
56 set srcfile ${testfile}.c
57 set binfile ${objdir}/${subdir}/${testfile}t
58 if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${libfile}" "${binfile}" executable [list debug "additional_flags=-Wl,-rpath,${objdir}/${subdir}"]] != ""} {
63 set coredir "${objdir}/${subdir}/coredir.[getpid]"
65 catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\""
67 foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" {
68 if [remote_file build exists $i] {
69 remote_exec build "mv $i ${objdir}/${subdir}/prelink.core"
73 # Check for "core.PID".
75 set names [glob -nocomplain -directory $coredir core.*]
76 if {[llength $names] == 1} {
77 set corefile [file join $coredir [lindex $names 0]]
78 remote_exec build "mv $corefile ${objdir}/${subdir}/prelink.core"
83 # Try to clean up after ourselves.
84 remote_file build delete [file join $coredir coremmap.data]
85 remote_exec build "rmdir $coredir"
88 warning "can't generate a core file - prelink tests suppressed - check ulimit -c"
92 if {[catch "system \"prelink -uN ${libfile}\""] != 0} {
93 untested "${libfile} was not prelinked, maybe system libraries are not prelinked?"
96 catch "system \"prelink -qNR ${libfile}\""
98 # Start with a fresh gdb
102 gdb_reinitialize_dir $srcdir/$subdir
107 gdb_test_multiple "core-file $objdir/$subdir/prelink.core" "$test" {
108 -re "warning: \.dynamic section.*not at the expected address.*warning: difference.*caused by prelink, adjusting expectations.*$gdb_prompt $" {