]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/testsuite/ld-scripts/phdrs.exp
Update year range in copyright notice of binutils files
[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.
250d07de 3# Copyright (C) 1999-2021 Free Software Foundation, Inc.
a2b64bed 4#
f96b4a7b
NC
5# This file is part of the GNU Binutils.
6#
7# This program is free software; you can redistribute it and/or modify
a2b64bed 8# it under the terms of the GNU General Public License as published by
f96b4a7b 9# the Free Software Foundation; either version 3 of the License, or
a2b64bed 10# (at your option) any later version.
7f9adacd 11#
a2b64bed
NC
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
7f9adacd 16#
a2b64bed
NC
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
f96b4a7b
NC
19# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20# MA 02110-1301, USA.
252b5132
RH
21
22# PHDRS is only meaningful for ELF.
7ed2b4e2 23if ![is_elf_format] {
252b5132
RH
24 return
25}
26
27# This is a very simplistic test.
28
29set testname "PHDRS"
30
e9f53129
AM
31set ldopt ""
32if { [istarget spu*-*-*] } {
33 set ldopt "--local-store 0:0"
34}
35
252b5132
RH
36if ![ld_assemble $as $srcdir/$subdir/phdrs.s tmpdir/phdrs.o] {
37 unresolved $testname
38 return
39}
40
41set phdrs_regexp \
7f9adacd 42".*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
43
44# On a 64 bit ELF format, we need different numbers.
7ed2b4e2
L
45if [is_elf64 tmpdir/phdrs.o] {
46 set phdrs_regexp \
7f9adacd 47".*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
48}
49
e9f53129 50set ldopt "$ldopt -T $srcdir/$subdir/phdrs.t tmpdir/phdrs.o"
d9816402 51if ![ld_link $ld tmpdir/phdrs $ldopt] {
252b5132
RH
52 fail $testname
53} else {
7f6a71ff 54 if {![is_remote host] && [which $objdump] == 0} {
252b5132
RH
55 unresolved $testname
56 return
57 }
e3b66208 58 set exec_output [run_host_cmd "$objdump" "--private-headers tmpdir/phdrs"]
252b5132
RH
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}