2010-01-01 08:32:07 +01:00
|
|
|
# Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
|
2006-02-28 05:29:10 +01:00
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
2007-08-23 20:14:19 +02:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
2006-02-28 05:29:10 +01:00
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-08-23 20:14:19 +02:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-02-28 05:29:10 +01:00
|
|
|
|
|
|
|
# Please email any bugs, comments, and/or additions to this file to:
|
2006-03-07 06:05:29 +01:00
|
|
|
# bug-gdb@gnu.org
|
2006-02-28 05:29:10 +01:00
|
|
|
|
|
|
|
# This file was written by Alexandre Oliva <aoliva@redhat.com>
|
|
|
|
|
|
|
|
if $tracelevel then {
|
|
|
|
strace $tracelevel
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# are we on a target board
|
|
|
|
if ![isnative] then {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if [get_compiler_info "ignored"] {
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
if {$gcc_compiled == 0} {
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
set testfile "prelink"
|
|
|
|
|
|
|
|
set libsrcfile ${testfile}-lib.c
|
|
|
|
set libfile ${objdir}/${subdir}/${testfile}.so
|
|
|
|
if { [gdb_compile "${srcdir}/${subdir}/${libsrcfile}" "${libfile}" executable [list debug "additional_flags=-fpic -shared -nodefaultlibs"]] != ""} {
|
|
|
|
# If creating the shared library fails, maybe we don't have the right tools
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
2008-03-24 16:16:12 +01:00
|
|
|
# `--no-exec-shield' is for i386 where prelink in the exec-shield mode is
|
|
|
|
# forced to push all the libraries tight together to fit into the first two
|
|
|
|
# memory areas (either the ASCII Shield area or at least below the executable).
|
|
|
|
# In this case its -R option cannot be applied and we falsely FAIL here as if
|
|
|
|
# the system is already prelinked prelink has no choice how to randomize the
|
|
|
|
# single new unprelinked library address without wasting the first one/two
|
|
|
|
# memory areas. We do not care of the efficiency of loading such resulting
|
|
|
|
# exec-shield unfriendly prelinked library.
|
|
|
|
if {[catch "system \"prelink -qNR --no-exec-shield ${libfile}\""] != 0} {
|
2006-02-28 05:29:10 +01:00
|
|
|
# Maybe we don't have prelink.
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
set srcfile ${testfile}.c
|
2006-03-07 06:05:29 +01:00
|
|
|
set binfile ${objdir}/${subdir}/${testfile}t
|
2006-02-28 05:29:10 +01:00
|
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${libfile}" "${binfile}" executable [list debug "additional_flags=-Wl,-rpath,${objdir}/${subdir}"]] != ""} {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
set found 0
|
|
|
|
set coredir "${objdir}/${subdir}/coredir.[getpid]"
|
|
|
|
file mkdir $coredir
|
|
|
|
catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\""
|
|
|
|
|
|
|
|
foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" {
|
|
|
|
if [remote_file build exists $i] {
|
|
|
|
remote_exec build "mv $i ${objdir}/${subdir}/prelink.core"
|
|
|
|
set found 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# Check for "core.PID".
|
|
|
|
if { $found == 0 } {
|
|
|
|
set names [glob -nocomplain -directory $coredir core.*]
|
|
|
|
if {[llength $names] == 1} {
|
|
|
|
set corefile [file join $coredir [lindex $names 0]]
|
|
|
|
remote_exec build "mv $corefile ${objdir}/${subdir}/prelink.core"
|
|
|
|
set found 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Try to clean up after ourselves.
|
|
|
|
remote_file build delete [file join $coredir coremmap.data]
|
|
|
|
remote_exec build "rmdir $coredir"
|
|
|
|
|
|
|
|
if { $found == 0 } {
|
|
|
|
warning "can't generate a core file - prelink tests suppressed - check ulimit -c"
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2006-03-07 06:05:29 +01:00
|
|
|
if {[catch "system \"prelink -uN ${libfile}\""] != 0} {
|
2007-02-27 14:54:04 +01:00
|
|
|
untested "${testfile}.so was not prelinked, maybe system libraries are not prelinked?"
|
2006-03-07 06:05:29 +01:00
|
|
|
return 0
|
|
|
|
}
|
2008-03-24 16:16:12 +01:00
|
|
|
catch "system \"prelink -qNR --no-exec-shield ${libfile}\""
|
2006-03-07 06:05:29 +01:00
|
|
|
|
2006-02-28 05:29:10 +01:00
|
|
|
# Start with a fresh gdb
|
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
gdb_start
|
|
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
|
|
|
gdb_load ${binfile}
|
|
|
|
|
2010-02-13 13:02:29 +01:00
|
|
|
# Print the "adjusting expectations" message.
|
2010-06-01 23:29:21 +02:00
|
|
|
gdb_test_no_output "set verbose on"
|
2010-02-13 13:02:29 +01:00
|
|
|
|
2010-03-11 23:07:03 +01:00
|
|
|
gdb_test "core-file $objdir/$subdir/prelink.core" {Using PIC \(Position Independent Code\) prelink displacement.*} "prelink"
|