]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/testsuite/ld-scripts/phdrs.exp
New Cell SPU port.
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-scripts / phdrs.exp
CommitLineData
252b5132
RH
1# Test PHDRS in a linker script.
2# By Ian Lance Taylor, Cygnus Support.
e9f53129 3# Copyright 1999, 2000, 2001, 2002, 2003, 2006
a2b64bed
NC
4# Free Software Foundation, Inc.
5#
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.
7f9adacd 10#
a2b64bed
NC
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.
7f9adacd 15#
a2b64bed
NC
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
75be928b 18# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
252b5132
RH
19
20# PHDRS is only meaningful for ELF.
7ed2b4e2 21if ![is_elf_format] {
252b5132
RH
22 return
23}
24
25# This is a very simplistic test.
26
27set testname "PHDRS"
28
e9f53129
AM
29set ldopt ""
30if { [istarget spu*-*-*] } {
31 set ldopt "--local-store 0:0"
32}
33
252b5132
RH
34if ![ld_assemble $as $srcdir/$subdir/phdrs.s tmpdir/phdrs.o] {
35 unresolved $testname
36 return
37}
38
39set phdrs_regexp \
7f9adacd 40".*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-.*"
252b5132
RH
41
42# On a 64 bit ELF format, we need different numbers.
7ed2b4e2
L
43if [is_elf64 tmpdir/phdrs.o] {
44 set phdrs_regexp \
7f9adacd 45".*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-.*"
252b5132
RH
46}
47
e9f53129
AM
48set ldopt "$ldopt -T $srcdir/$subdir/phdrs.t tmpdir/phdrs.o"
49if ![ld_simple_link $ld tmpdir/phdrs $ldopt] {
252b5132
RH
50 fail $testname
51} else {
52 if {[which $objdump] == 0} {
53 unresolved $testname
54 return
55 }
56
57 verbose -log "$objdump --private tmpdir/phdrs"
58 catch "exec $objdump --private tmpdir/phdrs" exec_output
59 set exec_output [prune_warnings $exec_output]
60 verbose -log $exec_output
61
62 if [regexp $phdrs_regexp $exec_output] {
63 pass $testname
64 } else {
65 fail $testname
66 }
67}