2017-01-01 07:50:51 +01:00
|
|
|
# Copyright 2006-2017 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>
|
|
|
|
|
|
|
|
|
2010-07-05 20:01:53 +02:00
|
|
|
if { ![isnative] || [is_remote host] || [skip_shlib_tests]} {
|
2006-02-28 05:29:10 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2012-06-21 22:46:25 +02:00
|
|
|
if [get_compiler_info] {
|
2006-02-28 05:29:10 +01:00
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
if {$gcc_compiled == 0} {
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
2010-07-05 20:01:53 +02:00
|
|
|
load_lib prelink-support.exp
|
|
|
|
|
2006-02-28 05:29:10 +01:00
|
|
|
set testfile "prelink"
|
|
|
|
|
|
|
|
set libsrcfile ${testfile}-lib.c
|
2013-08-23 20:18:01 +02:00
|
|
|
set libfile [standard_output_file ${testfile}.so]
|
2010-07-05 20:01:53 +02:00
|
|
|
|
|
|
|
# Use -soname so that the new library gets copied by build_executable_own_libs.
|
|
|
|
|
2010-10-12 20:12:49 +02:00
|
|
|
if { [gdb_compile_shlib "${srcdir}/${subdir}/${libsrcfile}" "${libfile}" [list debug "ldflags=-Wl,-soname,[file tail ${libfile}]"]] != ""} {
|
2006-02-28 05:29:10 +01:00
|
|
|
# If creating the shared library fails, maybe we don't have the right tools
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
2010-07-05 20:01:53 +02:00
|
|
|
set srcfile ${testfile}.c
|
|
|
|
set executable ${testfile}t
|
2013-08-23 20:18:01 +02:00
|
|
|
set binfile [standard_output_file ${executable}]
|
2010-10-12 20:12:49 +02:00
|
|
|
set prelink_args [build_executable_own_libs ${testfile}.exp $executable $srcfile [list debug "ldflags=-Wl,${libfile},-rpath,[file dirname ${libfile}]"]]
|
2010-07-05 20:01:53 +02:00
|
|
|
if {$prelink_args == ""} {
|
2006-02-28 05:29:10 +01:00
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
2010-07-30 18:04:30 +02:00
|
|
|
set test "split debug of executable"
|
|
|
|
if [gdb_gnu_strip_debug $binfile] {
|
|
|
|
fail $test
|
|
|
|
} else {
|
|
|
|
pass $test
|
|
|
|
}
|
|
|
|
|
2010-07-05 20:01:53 +02:00
|
|
|
if ![prelink_yes $prelink_args] {
|
|
|
|
# Maybe we don't have prelink.
|
|
|
|
return -1
|
2006-02-28 05:29:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
set found 0
|
2013-08-23 20:18:01 +02:00
|
|
|
set coredir "[standard_output_file coredir.[getpid]]"
|
2006-02-28 05:29:10 +01:00
|
|
|
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] {
|
2013-08-23 20:18:01 +02:00
|
|
|
remote_exec build "mv $i [standard_output_file prelink.core]"
|
2006-02-28 05:29:10 +01:00
|
|
|
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]]
|
2013-08-23 20:18:01 +02:00
|
|
|
remote_exec build "mv $corefile [standard_output_file prelink.core]"
|
2006-02-28 05:29:10 +01:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2010-07-05 20:01:53 +02:00
|
|
|
# Relink $libfile to a different address.
|
|
|
|
if ![prelink_yes $prelink_args] {
|
|
|
|
return -1
|
2006-03-07 06:05:29 +01:00
|
|
|
}
|
|
|
|
|
2006-02-28 05:29:10 +01:00
|
|
|
# Start with a fresh gdb
|
|
|
|
|
2010-07-05 20:01:53 +02:00
|
|
|
clean_restart $executable
|
2006-02-28 05:29:10 +01:00
|
|
|
|
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
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
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"
|
2010-07-30 18:04:30 +02:00
|
|
|
|
|
|
|
gdb_test "p &bssvar == bssvarp" " = 1" ".dynbss vs. .bss address shift"
|