1 |
98 |
khays |
# Test PHDRS in a linker script.
|
2 |
|
|
# By Ian Lance Taylor, Cygnus Support.
|
3 |
|
|
# Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007
|
4 |
|
|
# Free Software Foundation, Inc.
|
5 |
|
|
#
|
6 |
|
|
# This file is part of the GNU Binutils.
|
7 |
|
|
#
|
8 |
|
|
# This program is free software; you can redistribute it and/or modify
|
9 |
|
|
# it under the terms of the GNU General Public License as published by
|
10 |
|
|
# the Free Software Foundation; either version 3 of the License, or
|
11 |
|
|
# (at your option) any later version.
|
12 |
|
|
#
|
13 |
|
|
# This program is distributed in the hope that it will be useful,
|
14 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
|
|
# GNU General Public License for more details.
|
17 |
|
|
#
|
18 |
|
|
# You should have received a copy of the GNU General Public License
|
19 |
|
|
# along with this program; if not, write to the Free Software
|
20 |
|
|
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
21 |
|
|
# MA 02110-1301, USA.
|
22 |
|
|
|
23 |
|
|
# PHDRS is only meaningful for ELF.
|
24 |
|
|
if ![is_elf_format] {
|
25 |
|
|
return
|
26 |
|
|
}
|
27 |
|
|
|
28 |
|
|
# This is a very simplistic test.
|
29 |
|
|
|
30 |
|
|
set testname "PHDRS"
|
31 |
|
|
|
32 |
|
|
set ldopt ""
|
33 |
|
|
if { [istarget spu*-*-*] } {
|
34 |
|
|
set ldopt "--local-store 0:0"
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
if ![ld_assemble $as $srcdir/$subdir/phdrs.s tmpdir/phdrs.o] {
|
38 |
|
|
unresolved $testname
|
39 |
|
|
return
|
40 |
|
|
}
|
41 |
|
|
|
42 |
|
|
set phdrs_regexp \
|
43 |
|
|
".*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-.*"
|
44 |
|
|
|
45 |
|
|
# On a 64 bit ELF format, we need different numbers.
|
46 |
|
|
if [is_elf64 tmpdir/phdrs.o] {
|
47 |
|
|
set phdrs_regexp \
|
48 |
|
|
".*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-.*"
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
set ldopt "$ldopt -T $srcdir/$subdir/phdrs.t tmpdir/phdrs.o"
|
52 |
|
|
if ![ld_simple_link $ld tmpdir/phdrs $ldopt] {
|
53 |
|
|
fail $testname
|
54 |
|
|
} else {
|
55 |
|
|
if {![is_remote host] && [which $objdump] == 0} {
|
56 |
|
|
unresolved $testname
|
57 |
|
|
return
|
58 |
|
|
}
|
59 |
|
|
set exec_output [run_host_cmd "$objdump" "--private-headers tmpdir/phdrs"]
|
60 |
|
|
set exec_output [prune_warnings $exec_output]
|
61 |
|
|
verbose -log $exec_output
|
62 |
|
|
|
63 |
|
|
if [regexp $phdrs_regexp $exec_output] {
|
64 |
|
|
pass $testname
|
65 |
|
|
} else {
|
66 |
|
|
fail $testname
|
67 |
|
|
}
|
68 |
|
|
}
|