* ld-scripts/phdrs.exp: x86-64 is a 64 bit ELF platform, handle it
[binutils.git] / ld / testsuite / ld-scripts / phdrs.exp
blobf0bc1ad5489b55db827b8f10fba275fc4f962914
1 # Test PHDRS in a linker script.
2 # By Ian Lance Taylor, Cygnus Support.
3 # Copyright 2001
4 # Free Software Foundation, Inc.
6 # This file is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 # PHDRS is only meaningful for ELF.
21 if { ![istarget *-*-sysv4*] \
22 && ![istarget *-*-unixware*] \
23 && ![istarget *-*-elf*] \
24 && ![istarget *-*-eabi*] \
25 && ![istarget *-*-linux*] \
26 && ![istarget *-*-irix5*] \
27 && ![istarget *-*-irix6*] \
28 && ![istarget *-*-solaris2*] } {
29 return
32 if { [istarget *-*-linux*aout*] \
33 || [istarget *-*-linux*oldld*] } {
34 return
37 # This is a very simplistic test.
39 set testname "PHDRS"
41 if ![ld_assemble $as $srcdir/$subdir/phdrs.s tmpdir/phdrs.o] {
42 unresolved $testname
43 return
46 set phdrs_regexp \
47 ".*Program Header:.*PHDR *off *0x00*34 *vaddr *0x00*80034 *paddr *0x00*80034.*filesz *0x0\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* flags r--.*LOAD *off *0x00* *vaddr *0x00*80000 *paddr *0x00*80000.*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-.*"
49 # On a 64 bit ELF format, we need different numbers.
50 if { [istarget alpha*-*-*] || [istarget "ia64*-*-*"]
51 || [istarget "hppa*64*-*-*"] || [istarget "x86_64*-*-*"] } then {
52 set phdrs_regexp \
53 ".*Program Header:.*PHDR *off *0x00*40 *vaddr *0x00*80040 *paddr *0x00*80040.*filesz *0x0\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* flags r--.*LOAD *off *0x00* *vaddr *0x00*80000 *paddr *0x00*80000.*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-.*"
56 if ![ld_simple_link $ld tmpdir/phdrs "-T $srcdir/$subdir/phdrs.t tmpdir/phdrs.o"] {
57 fail $testname
58 } else {
59 if {[which $objdump] == 0} {
60 unresolved $testname
61 return
64 verbose -log "$objdump --private tmpdir/phdrs"
65 catch "exec $objdump --private tmpdir/phdrs" exec_output
66 set exec_output [prune_warnings $exec_output]
67 verbose -log $exec_output
69 if [regexp $phdrs_regexp $exec_output] {
70 pass $testname
71 } else {
72 fail $testname