From 5c1a3f0fa74b2b0cc679d03e4158b4f37ae973f1 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Wed, 7 Oct 2009 07:25:36 +0000 Subject: ld/ * ldlang.c (lang_new_phdr): Check PHDRS and FILEHDR in loadable segments do not appear after a different loadable segment. * ld.texinfo (PHDRS): Document order of processing segments. Document where PHDRS and FILEHDR may appear. ld/testsuite/ * ld-scripts/phdrs3.d: New. * ld-scripts/phdrs3.t: New. * ld-scripts/phdrs3.exp: New. --- ld/testsuite/ld-scripts/phdrs3.d | 4 ++++ ld/testsuite/ld-scripts/phdrs3.exp | 38 ++++++++++++++++++++++++++++++++++++++ ld/testsuite/ld-scripts/phdrs3.t | 16 ++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 ld/testsuite/ld-scripts/phdrs3.d create mode 100644 ld/testsuite/ld-scripts/phdrs3.exp create mode 100644 ld/testsuite/ld-scripts/phdrs3.t (limited to 'ld/testsuite/ld-scripts') diff --git a/ld/testsuite/ld-scripts/phdrs3.d b/ld/testsuite/ld-scripts/phdrs3.d new file mode 100644 index 0000000..78fe4e4 --- /dev/null +++ b/ld/testsuite/ld-scripts/phdrs3.d @@ -0,0 +1,4 @@ +# name: PHDRS headers +# source: phdrs.s +# ld: -T phdrs3.t +# error: \A[^ \n:]*:[^:\n]*:5: PHDRS and FILEHDR are only permitted for the first PT_LOAD segment\Z diff --git a/ld/testsuite/ld-scripts/phdrs3.exp b/ld/testsuite/ld-scripts/phdrs3.exp new file mode 100644 index 0000000..90651af --- /dev/null +++ b/ld/testsuite/ld-scripts/phdrs3.exp @@ -0,0 +1,38 @@ +# Test PHDRS in a linker script. +# By Nathan Sidwell +# Copyright 2009 Free Software Foundation, Inc. +# +# This file is part of the GNU Binutils. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. + +# PHDRS is only meaningful for ELF. +if ![is_elf_format] { + return +} + +load_lib ld-lib.exp + +set testname "PHDRS headers" + +set old_ldflags $LDFLAGS +if { [istarget spu*-*-*] } { + set LDFLAGS "$LDFLAGS --no-overlays" +} + +run_dump_test "phdrs3" + +set LDFLAGS $old_ldflags diff --git a/ld/testsuite/ld-scripts/phdrs3.t b/ld/testsuite/ld-scripts/phdrs3.t new file mode 100644 index 0000000..4bd4e85 --- /dev/null +++ b/ld/testsuite/ld-scripts/phdrs3.t @@ -0,0 +1,16 @@ +PHDRS +{ + data PT_LOAD ; + header PT_PHDR PHDRS ; /* OK */ + text PT_LOAD FILEHDR PHDRS ; +} + +SECTIONS +{ + /* This test will fail on architectures where the startaddress below + is less than the constant MAXPAGESIZE. */ + . = 0x800000 + SIZEOF_HEADERS; + .text : { *(.text) } :text + .data : { *(.data) } :data + /DISCARD/ : { *(.*) } +} -- cgit v1.1