Support different ld --hash-style in the ld testsuite
[deliverable/binutils-gdb.git] / ld / testsuite / ld-scripts / phdrs.exp
... / ...
CommitLineData
1# Test PHDRS in a linker script.
2# By Ian Lance Taylor, Cygnus Support.
3# Copyright (C) 1999-2017 Free Software Foundation, Inc.
4#
5# This file is part of the GNU Binutils.
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 3 of the License, or
10# (at your option) any later version.
11#
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.
16#
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
19# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20# MA 02110-1301, USA.
21
22# PHDRS is only meaningful for ELF.
23if ![is_elf_format] {
24 return
25}
26
27# This is a very simplistic test.
28
29set testname "PHDRS"
30
31set ldopt ""
32if { [istarget spu*-*-*] } {
33 set ldopt "--local-store 0:0"
34}
35
36if ![ld_assemble $as $srcdir/$subdir/phdrs.s tmpdir/phdrs.o] {
37 unresolved $testname
38 return
39}
40
41set phdrs_regexp \
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-.*"
43
44# On a 64 bit ELF format, we need different numbers.
45if [is_elf64 tmpdir/phdrs.o] {
46 set phdrs_regexp \
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-.*"
48}
49
50set ldopt "$ldopt -T $srcdir/$subdir/phdrs.t tmpdir/phdrs.o"
51if ![ld_link $ld tmpdir/phdrs $ldopt] {
52 fail $testname
53} else {
54 if {![is_remote host] && [which $objdump] == 0} {
55 unresolved $testname
56 return
57 }
58 set exec_output [run_host_cmd "$objdump" "--private-headers tmpdir/phdrs"]
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}
This page took 0.022568 seconds and 4 git commands to generate.