2000-10-31 Philip Blundell <philb@gnu.org>
[binutils.git] / ld / testsuite / ld-scripts / phdrs.exp
blobf52bc93f3f9a8762118ed238223a340675a7b1c7
1 # Test PHDRS in a linker script.
2 # By Ian Lance Taylor, Cygnus Support.
4 # PHDRS is only meaningful for ELF.
5 if { ![istarget *-*-sysv4*] \
6 && ![istarget *-*-unixware*] \
7 && ![istarget *-*-elf*] \
8 && ![istarget *-*-eabi*] \
9 && ![istarget *-*-linux*] \
10 && ![istarget *-*-irix5*] \
11 && ![istarget *-*-irix6*] \
12 && ![istarget *-*-solaris2*] } {
13 return
16 if { [istarget *-*-linux*aout*] \
17 || [istarget *-*-linux*oldld*] } {
18 return
21 # This is a very simplistic test.
23 set testname "PHDRS"
25 if ![ld_assemble $as $srcdir/$subdir/phdrs.s tmpdir/phdrs.o] {
26 unresolved $testname
27 return
30 set phdrs_regexp \
31 ".*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-.*"
33 # On a 64 bit ELF format, we need different numbers.
34 if { [istarget alpha*-*-*] || [istarget "ia64*-*-*"]
35 || [istarget "hppa*64*-*-*"] } then {
36 set phdrs_regexp \
37 ".*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-.*"
40 if ![ld_simple_link $ld tmpdir/phdrs "-T $srcdir/$subdir/phdrs.t tmpdir/phdrs.o"] {
41 fail $testname
42 } else {
43 if {[which $objdump] == 0} {
44 unresolved $testname
45 return
48 verbose -log "$objdump --private tmpdir/phdrs"
49 catch "exec $objdump --private tmpdir/phdrs" exec_output
50 set exec_output [prune_warnings $exec_output]
51 verbose -log $exec_output
53 if [regexp $phdrs_regexp $exec_output] {
54 pass $testname
55 } else {
56 fail $testname