1999-05-03 07:29:11 +00:00
|
|
|
# Test PHDRS in a linker script.
|
|
|
|
# By Ian Lance Taylor, Cygnus Support.
|
2001-03-13 06:14:29 +00:00
|
|
|
# Copyright 2001
|
|
|
|
# Free Software Foundation, Inc.
|
|
|
|
#
|
|
|
|
# This file is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
2001-05-01 08:07:35 +00:00
|
|
|
#
|
2001-03-13 06:14:29 +00:00
|
|
|
# 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.
|
2001-05-01 08:07:35 +00:00
|
|
|
#
|
2001-03-13 06:14:29 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
# PHDRS is only meaningful for ELF.
|
|
|
|
if { ![istarget *-*-sysv4*] \
|
|
|
|
&& ![istarget *-*-unixware*] \
|
|
|
|
&& ![istarget *-*-elf*] \
|
|
|
|
&& ![istarget *-*-eabi*] \
|
* ld-discard/discard.exp, ld-scripts/phdrs.exp, ld-scripts/phdrs2.exp,
ld-selective/sel-dump.exp: Test hppa*64*-*-hpux* target.
* ld-elfvers/vers.exp, ld-elfvsb/elfvsb.exp, ld-elfweak/elfweak.exp,
ld-linkonce/linkonce.exp, ld-shared/shared.exp,
ld-undefined/weak-undef.exp: Test hppa*64*-*-hpux* and hppa*-*-linux*
targets.
* ld-discard/exit.s, ld-discard/extern.s, ld-discard/start.s,
ld-discard/static.s: Add whitespace before assembler directives.
2002-07-30 07:41:15 +00:00
|
|
|
&& ![istarget hppa*64*-*-hpux*] \
|
1999-05-03 07:29:11 +00:00
|
|
|
&& ![istarget *-*-linux*] \
|
|
|
|
&& ![istarget *-*-irix5*] \
|
|
|
|
&& ![istarget *-*-irix6*] \
|
|
|
|
&& ![istarget *-*-solaris2*] } {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
1999-06-12 10:47:08 +00:00
|
|
|
if { [istarget *-*-linux*aout*] \
|
|
|
|
|| [istarget *-*-linux*oldld*] } {
|
1999-05-03 07:29:11 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
# This is a very simplistic test.
|
|
|
|
|
|
|
|
set testname "PHDRS"
|
|
|
|
|
|
|
|
if ![ld_assemble $as $srcdir/$subdir/phdrs.s tmpdir/phdrs.o] {
|
|
|
|
unresolved $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
set phdrs_regexp \
|
2001-05-01 08:07:35 +00:00
|
|
|
".*Program Header:.*PHDR *off *0x00*34 *vaddr *0x00*800034 *paddr *0x00*800034.*filesz *0x0\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* flags r--.*LOAD *off *0x00* *vaddr *0x00*800000 *paddr *0x00*800000.*filesz *0x00*\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* *flags r-x.*LOAD *off *0x0\[0-9a-f\]* *vaddr *0x00*80*\[0-9a-f\]* *paddr *0x00*80*\[0-9a-f\]*.*filesz *0x0\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* *flags *rw-.*"
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
# On a 64 bit ELF format, we need different numbers.
|
2000-10-07 13:57:29 +00:00
|
|
|
if { [istarget alpha*-*-*] || [istarget "ia64*-*-*"]
|
2001-05-01 08:07:35 +00:00
|
|
|
|| [istarget "hppa*64*-*-*"] || [istarget "x86_64*-*-*"]
|
2001-08-27 10:49:55 +00:00
|
|
|
|| [istarget "s390x*-*-*"] || [istarget "sparc64*-*-*"]
|
|
|
|
|| [istarget "powerpc64*-*-*"] || [istarget "*-*-*elf64*"] } then {
|
1999-05-03 07:29:11 +00:00
|
|
|
set phdrs_regexp \
|
2001-05-01 08:07:35 +00:00
|
|
|
".*Program Header:.*PHDR *off *0x00*40 *vaddr *0x00*800040 *paddr *0x00*800040.*filesz *0x0\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* flags r--.*LOAD *off *0x00* *vaddr *0x00*800000 *paddr *0x00*800000.*filesz *0x00*\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* *flags r-x.*LOAD *off *0x0\[0-9a-f\]* *vaddr *0x00*80*\[0-9a-f\]* *paddr *0x00*80*\[0-9a-f\]*.*filesz *0x0\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* *flags *rw-.*"
|
1999-05-03 07:29:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ![ld_simple_link $ld tmpdir/phdrs "-T $srcdir/$subdir/phdrs.t tmpdir/phdrs.o"] {
|
|
|
|
fail $testname
|
|
|
|
} else {
|
|
|
|
if {[which $objdump] == 0} {
|
|
|
|
unresolved $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
verbose -log "$objdump --private tmpdir/phdrs"
|
|
|
|
catch "exec $objdump --private tmpdir/phdrs" exec_output
|
|
|
|
set exec_output [prune_warnings $exec_output]
|
|
|
|
verbose -log $exec_output
|
|
|
|
|
|
|
|
if [regexp $phdrs_regexp $exec_output] {
|
|
|
|
pass $testname
|
|
|
|
} else {
|
|
|
|
fail $testname
|
|
|
|
}
|
|
|
|
}
|