diff options
author | Ben Cheng <bccheng@google.com> | 2014-03-26 11:03:35 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2014-03-26 11:03:35 -0700 |
commit | 09797ba54abf3683ea66eedddf6afbe7653f9cb9 (patch) | |
tree | 8030b2ed79c7463c89d6da294782e9d503c84f50 /binutils-2.24/ld/testsuite/ld-scripts | |
parent | 5a2caf34e4995860baf405552163df288000b7bf (diff) | |
download | toolchain_binutils-09797ba54abf3683ea66eedddf6afbe7653f9cb9.zip toolchain_binutils-09797ba54abf3683ea66eedddf6afbe7653f9cb9.tar.gz toolchain_binutils-09797ba54abf3683ea66eedddf6afbe7653f9cb9.tar.bz2 |
Initial checkin of binutils 2.24.
Change-Id: I0dfcbae6608dded6c3586bf5f4ac27e9612e70a2
Diffstat (limited to 'binutils-2.24/ld/testsuite/ld-scripts')
248 files changed, 4203 insertions, 0 deletions
diff --git a/binutils-2.24/ld/testsuite/ld-scripts/align-with-input.d b/binutils-2.24/ld/testsuite/ld-scripts/align-with-input.d new file mode 100644 index 0000000..f9c30d3 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/align-with-input.d @@ -0,0 +1,3 @@ +#source: script.s +#ld: -T align-with-input.t +#error: .*:[0-9]+: error: align with input and explicit align specified diff --git a/binutils-2.24/ld/testsuite/ld-scripts/align-with-input.t b/binutils-2.24/ld/testsuite/ld-scripts/align-with-input.t new file mode 100644 index 0000000..616061c --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/align-with-input.t @@ -0,0 +1,5 @@ +SECTIONS { + .abc : ALIGN(1) ALIGN_WITH_INPUT { + *(.abc) + } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/align.exp b/binutils-2.24/ld/testsuite/ld-scripts/align.exp new file mode 100644 index 0000000..9ea46d0 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/align.exp @@ -0,0 +1,53 @@ +# Test ALIGN in a linker script. +# By Nathan Sidwell, CodeSourcery LLC +# Copyright 2004, 2005, 2006, 2007 +# 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. + +if [istarget "rs6000-*-aix*"] { + # Target maps .text and .data to other sections. + return +} + +set testname "align1" + +if ![ld_assemble $as $srcdir/$subdir/align.s tmpdir/align.o] { + unresolved $testname + return +} + +# mingw on x86_64 targets need to set the image base to 0 to avoid auto image-basing. +global LDFLAGS +set saved_LDFLAGS "$LDFLAGS" +if [istarget "x86_64-*-mingw*"] then { + set LDFLAGS "$LDFLAGS --image-base 0" +} + +if ![ld_simple_link $ld tmpdir/align "$LDFLAGS -T $srcdir/$subdir/align.t tmpdir/align.o"] { + fail $testname +} else { + pass $testname +} + +if ![is_aout_format] { + run_dump_test align2a + run_dump_test align2b +} +run_dump_test align2c +set LDFLAGS "$saved_LDFLAGS" diff --git a/binutils-2.24/ld/testsuite/ld-scripts/align.s b/binutils-2.24/ld/testsuite/ld-scripts/align.s new file mode 100644 index 0000000..c9bad23 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/align.s @@ -0,0 +1,2 @@ + .text + .long 0 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/align.t b/binutils-2.24/ld/testsuite/ld-scripts/align.t new file mode 100644 index 0000000..49d6053 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/align.t @@ -0,0 +1,8 @@ +SECTIONS +{ + .text : {*(.text)} + .data ALIGN(0x40) : AT (ALIGN (LOADADDR (.text) + SIZEOF (.text), 0x80)) + {} + ASSERT (LOADADDR(.data) == 0x80, "dyadic ALIGN broken") + ASSERT (ADDR(.data) == 0x40, "monadic ALIGN broken") +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/align2.t b/binutils-2.24/ld/testsuite/ld-scripts/align2.t new file mode 100644 index 0000000..d86f62a --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/align2.t @@ -0,0 +1,7 @@ +SECTIONS +{ + .text : {*(.text)} + . = ALIGN(data_align); + .data : {*(.data)} + /DISCARD/ : {*(*)} +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/align2a.d b/binutils-2.24/ld/testsuite/ld-scripts/align2a.d new file mode 100644 index 0000000..96237dd --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/align2a.d @@ -0,0 +1,12 @@ +# ld: --defsym data_align=16 -T align2.t +# objdump: --section-headers + +[^:]+: +file format.* + +Sections: +Idx +Name +Size +VMA +LMA +File +off +Algn +[ ]+0 +\.text +[^ ]* +0+ +0+ .* +[ ]+CONTENTS, +ALLOC, +LOAD,.* CODE +[ ]+1 +\.data +[^ ]* +0+10 +0+10 .* +[ ]+CONTENTS, +ALLOC, +LOAD, +DATA +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/align2a.s b/binutils-2.24/ld/testsuite/ld-scripts/align2a.s new file mode 100644 index 0000000..4e56d4a --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/align2a.s @@ -0,0 +1,4 @@ + .text + .long 0 + .data + .long 0x12345678 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/align2b.d b/binutils-2.24/ld/testsuite/ld-scripts/align2b.d new file mode 100644 index 0000000..05d2a15 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/align2b.d @@ -0,0 +1,12 @@ +# ld: --defsym data_align=32 -T align2.t +# objdump: --section-headers + +[^:]+: +file +format.* + +Sections: +Idx +Name +Size +VMA +LMA +File off +Algn + +0 +\.text +[^ ]* +0+ +0+ .* + +CONTENTS, +ALLOC, +LOAD,.* CODE + +1 +\.data +[^ ]* +0+20 +0+20 .* + +CONTENTS, +ALLOC, +LOAD, +DATA +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/align2b.s b/binutils-2.24/ld/testsuite/ld-scripts/align2b.s new file mode 100644 index 0000000..4e56d4a --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/align2b.s @@ -0,0 +1,4 @@ + .text + .long 0 + .data + .long 0x12345678 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/align2c.d b/binutils-2.24/ld/testsuite/ld-scripts/align2c.d new file mode 100644 index 0000000..16a4245 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/align2c.d @@ -0,0 +1,2 @@ +# ld: -T align2.t +# error: undefined symbol.*in expression diff --git a/binutils-2.24/ld/testsuite/ld-scripts/align2c.s b/binutils-2.24/ld/testsuite/ld-scripts/align2c.s new file mode 100644 index 0000000..4e56d4a --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/align2c.s @@ -0,0 +1,4 @@ + .text + .long 0 + .data + .long 0x12345678 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/alignof.exp b/binutils-2.24/ld/testsuite/ld-scripts/alignof.exp new file mode 100644 index 0000000..0f05aeb --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/alignof.exp @@ -0,0 +1,67 @@ +# Test ALIGNOF in a linker script. +# Copyright 2007 Free Software Foundation, Inc. +# Contributed by Nathan Sidwell <nathan@codesourcery.com> +# +# 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. + +# Only ELF and PE-COFF targets record section alignment. + +if {![is_elf_format] && ![is_pecoff_format]} { + return +} + +set testname "ALIGNOF" + +if ![ld_assemble $as $srcdir/$subdir/alignof.s tmpdir/alignof.o] { + unresolved $testname + return +} + +if ![ld_simple_link $ld tmpdir/alignof "-T $srcdir/$subdir/alignof.t tmpdir/alignof.o"] { + fail $testname + return +} + +if ![ld_nm $nm "" tmpdir/alignof] { + unresolved $testname + return +} + +if {![info exists nm_output(alignof_text)] \ + || ![info exists nm_output(alignof_data)]} { + send_log "bad output from nm\n" + verbose "bad output from nm" + fail $testname + return +} + +if {$nm_output(alignof_text) != 64} { + send_log "alignof_text != 64\n" + verbose "alignof_text != 64" + fail $testname + return +} + +if {$nm_output(alignof_data) != 16} { + send_log "alignof_data != 16\n" + verbose "alignof_data != 16" + fail $testname + return +} + +pass $testname diff --git a/binutils-2.24/ld/testsuite/ld-scripts/alignof.s b/binutils-2.24/ld/testsuite/ld-scripts/alignof.s new file mode 100644 index 0000000..d440d2e --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/alignof.s @@ -0,0 +1,9 @@ + + .text + .p2align 6 + .long 0 + + .data + .p2align 4 + .long 0 + diff --git a/binutils-2.24/ld/testsuite/ld-scripts/alignof.t b/binutils-2.24/ld/testsuite/ld-scripts/alignof.t new file mode 100644 index 0000000..1241112 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/alignof.t @@ -0,0 +1,15 @@ +SECTIONS { + .text : + { + tmpdir/alignof.o (.text) + } + .data : + { + tmpdir/alignof.o (.data) + LONG (ALIGNOF(.text)) + LONG (ALIGNOF(.data)) + } +} + +alignof_text = ALIGNOF(.text); +alignof_data = ALIGNOF(.data); diff --git a/binutils-2.24/ld/testsuite/ld-scripts/assert.exp b/binutils-2.24/ld/testsuite/ld-scripts/assert.exp new file mode 100644 index 0000000..b4169ac --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/assert.exp @@ -0,0 +1,36 @@ +# Test ASSERT in a linker script. +# By Nathan Sidwell, CodeSourcery LLC +# Copyright 2004, 2005, 2007 +# 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. + +set testname "ASSERT" + +if ![ld_assemble $as $srcdir/$subdir/assert.s tmpdir/assert.o] { + unresolved $testname + return +} + +if ![ld_simple_link $ld tmpdir/assert "-T $srcdir/$subdir/assert.t tmpdir/assert.o"] { + fail $testname +} else { + pass $testname +} + +run_dump_test "assert2" diff --git a/binutils-2.24/ld/testsuite/ld-scripts/assert.s b/binutils-2.24/ld/testsuite/ld-scripts/assert.s new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/assert.s @@ -0,0 +1 @@ + diff --git a/binutils-2.24/ld/testsuite/ld-scripts/assert.t b/binutils-2.24/ld/testsuite/ld-scripts/assert.t new file mode 100644 index 0000000..9b4c641 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/assert.t @@ -0,0 +1,10 @@ +SECTIONS +{ + .empty : { + here = . == ADDR(.empty); + ASSERT (. == ADDR(.empty), "dot is not ADDR"); + ASSERT (here, "here is zero"); + } + ASSERT (!SIZEOF(.empty), "Empty is not empty") + /DISCARD/ : { *(.reginfo) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/assert2.d b/binutils-2.24/ld/testsuite/ld-scripts/assert2.d new file mode 100644 index 0000000..4302def --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/assert2.d @@ -0,0 +1,3 @@ +# source: assert.s +# ld: -T assert2.t +# error: assert failed diff --git a/binutils-2.24/ld/testsuite/ld-scripts/assert2.t b/binutils-2.24/ld/testsuite/ld-scripts/assert2.t new file mode 100644 index 0000000..f6a9822 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/assert2.t @@ -0,0 +1 @@ +ASSERT(2 * 2 == 5, "assert failed"); diff --git a/binutils-2.24/ld/testsuite/ld-scripts/assign-loc.d b/binutils-2.24/ld/testsuite/ld-scripts/assign-loc.d new file mode 100644 index 0000000..bf6b9d8 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/assign-loc.d @@ -0,0 +1,11 @@ +#ld: -T assign-loc.t +#source: data.s +#nm: -n +#notarget: rs6000-*-aix* +#... +0+0100 A HEAP_SIZE +#... +0+2000 [AB] _start +#... +0+2100 [AB] _end +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/assign-loc.t b/binutils-2.24/ld/testsuite/ld-scripts/assign-loc.t new file mode 100644 index 0000000..e8c5102 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/assign-loc.t @@ -0,0 +1,17 @@ +SECTIONS +{ + . = 0x2000 ; + + _start = .; + + HEAP_SIZE = 0x100; + + .heap : { + . = HEAP_SIZE; + . = ALIGN(4); + } + + _end = .; + + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/cross1.c b/binutils-2.24/ld/testsuite/ld-scripts/cross1.c new file mode 100644 index 0000000..5678945 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/cross1.c @@ -0,0 +1,6 @@ +extern int foo (); +int +func () +{ + return foo (); +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/cross1.t b/binutils-2.24/ld/testsuite/ld-scripts/cross1.t new file mode 100644 index 0000000..c20e473 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/cross1.t @@ -0,0 +1,10 @@ +NOCROSSREFS ( .text .data ) +SECTIONS +{ + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .hash : { *(.hash) } + .toc : { *(.toc) } + .text : { tmpdir/cross1.o } + .data : { tmpdir/cross2.o } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/cross2.c b/binutils-2.24/ld/testsuite/ld-scripts/cross2.c new file mode 100644 index 0000000..4143177 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/cross2.c @@ -0,0 +1,5 @@ +int +foo () +{ + return 1; +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/cross2.t b/binutils-2.24/ld/testsuite/ld-scripts/cross2.t new file mode 100644 index 0000000..a0cdcbb --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/cross2.t @@ -0,0 +1,6 @@ +NOCROSSREFS ( .text .data ) +SECTIONS +{ + .text : { *(.text) *(.text.*) *(.pr) } + .data : { *(.data) *(.data.*) *(.sdata) *(.rw) *(.tc0) *(.tc) *(.toc) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/cross3.c b/binutils-2.24/ld/testsuite/ld-scripts/cross3.c new file mode 100644 index 0000000..1848c32 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/cross3.c @@ -0,0 +1,7 @@ +int i = 4; + +int +foo () +{ + return i; +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/cross3.t b/binutils-2.24/ld/testsuite/ld-scripts/cross3.t new file mode 100644 index 0000000..5e32bb2 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/cross3.t @@ -0,0 +1,10 @@ +NOCROSSREFS(.nocrossrefs .text) + +SECTIONS +{ + .text : { *(.text) } + .nocrossrefs : { *(.nocrossrefs) } + .data : { *(.data) *(.opd) } + .bss : { *(.bss) *(COMMON) } + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/cross4.c b/binutils-2.24/ld/testsuite/ld-scripts/cross4.c new file mode 100644 index 0000000..aef8dfd --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/cross4.c @@ -0,0 +1,7 @@ +__attribute__ ((section (".nocrossrefs"))) +static void +foo () +{ +} + +void (*dummy) () = foo; diff --git a/binutils-2.24/ld/testsuite/ld-scripts/crossref.exp b/binutils-2.24/ld/testsuite/ld-scripts/crossref.exp new file mode 100644 index 0000000..01fdeb4 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/crossref.exp @@ -0,0 +1,148 @@ +# Test NOCROSSREFS in a linker script. +# By Ian Lance Taylor, Cygnus Support. +# Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2007 +# 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. + +set test1 "NOCROSSREFS 1" +set test2 "NOCROSSREFS 2" +set test3 "NOCROSSREFS 3" + +if { ![is_remote host] && [which $CC] == 0 } { + untested $test1 + untested $test2 + untested $test3 + return +} + +global CFLAGS +set old_CFLAGS "$CFLAGS" + +# Xtensa targets currently default to putting literal values in a separate +# section and that requires linker script support, so put literals in text. +if [istarget xtensa*-*-*] { + set CFLAGS "$CFLAGS -mtext-section-literals" +} + +# If we have a compiler that doesn't use/reference dot-symbols, then +# calls to functions reference the .opd section function descriptor. +# This makes NOCROSSREFS rather useless on powerpc64. +if [istarget powerpc64-*-*] { + set CFLAGS "$CFLAGS -mcall-aixdesc" +} + +# Prevent the use of the MeP's small data area which references a symbol +# called __sdabase which will not be defined by our test linker scripts. +if [istarget mep*-*-elf] { + set CFLAGS "-mtiny=0" +} + +# The .dsbt section and __c6xabi_DSBT_BASE are not defined in our test +# linker scripts. +if [istarget tic6x*-*-*] { + set CFLAGS "-mno-dsbt -msdata=none" +} + +if { ![ld_compile $CC "$srcdir/$subdir/cross1.c" tmpdir/cross1.o] \ + || ![ld_compile $CC "$srcdir/$subdir/cross2.c" tmpdir/cross2.o] } { + unresolved $test1 + unresolved $test2 + set CFLAGS "$old_CFLAGS" + return +} + +set flags [big_or_little_endian] + +if [istarget sh64*-*-elf] { + # This is what gcc passes to ld by default. + set flags "-mshelf32" +} + +# IA64 has both ordered and unordered sections in an input file. +setup_xfail ia64-*-* + +set exec_output [run_host_cmd "$ld" "$flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o"] + +set exec_output [prune_warnings $exec_output] + +regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output + +if [string match "" $exec_output] then { + fail $test1 +} else { + verbose -log "$exec_output" + if [regexp "prohibited cross reference from .* to `.*foo' in" $exec_output] { + pass $test1 + } else { + fail $test1 + } +} + +# Check cross references within a single object. + +if { ![ld_compile $CC "$srcdir/$subdir/cross3.c" tmpdir/cross3.o] } { + unresolved $test2 + set CFLAGS "$old_CFLAGS" + return +} + +set exec_output [run_host_cmd "$ld" "$flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o"] +set exec_output [prune_warnings $exec_output] + +regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output + +if [string match "" $exec_output] then { + fail $test2 +} else { + verbose -log "$exec_output" + if [regexp "prohibited cross reference from .* to `.*' in" $exec_output] { + pass $test2 + } else { + fail $test2 + } +} + +# Check cross references for ld -r + +if { ![ld_compile $CC "$srcdir/$subdir/cross4.c" tmpdir/cross4.o] } { + unresolved $test3 + set CFLAGS "$old_CFLAGS" + return +} + +if ![ld_relocate $ld tmpdir/cross3-partial.o "tmpdir/cross1.o tmpdir/cross4.o"] { + unresolved $test3 + set CFLAGS "$old_CFLAGS" + return +} + +set exec_output [run_host_cmd "$ld" "$flags -o tmpdir/cross3 -T $srcdir/$subdir/cross3.t tmpdir/cross3-partial.o tmpdir/cross2.o"] + +set exec_output [prune_warnings $exec_output] + +regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output + +if [string match "" $exec_output] then { + pass $test3 +} else { + verbose -log "$exec_output" + fail $test3 +} + +set CFLAGS "$old_CFLAGS" diff --git a/binutils-2.24/ld/testsuite/ld-scripts/data.d b/binutils-2.24/ld/testsuite/ld-scripts/data.d new file mode 100644 index 0000000..10b3d08 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/data.d @@ -0,0 +1,9 @@ +#source: data.s +#ld: -T data.t +#objdump: -s -j .text + +.*: file format .* + +Contents of section .text: + [0-9a-f]* (04)?000000(04)? (0020)?0000(2000)? .* +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/data.exp b/binutils-2.24/ld/testsuite/ld-scripts/data.exp new file mode 100644 index 0000000..feb22aa --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/data.exp @@ -0,0 +1,30 @@ +# Test DATA STATEMENT in a linker script. +# By Nathan Sidwell, CodeSourcery LLC +# Copyright 2004, 2005, 2007 +# 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. + +# An a.out "objdump -s -j .text" has the file header visible inside the +# text segment, confusing run_dump_test. +if {[is_aout_format]} { + unsupported data + return +} + +run_dump_test data diff --git a/binutils-2.24/ld/testsuite/ld-scripts/data.s b/binutils-2.24/ld/testsuite/ld-scripts/data.s new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/data.s @@ -0,0 +1 @@ + diff --git a/binutils-2.24/ld/testsuite/ld-scripts/data.t b/binutils-2.24/ld/testsuite/ld-scripts/data.t new file mode 100644 index 0000000..f56d10f --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/data.t @@ -0,0 +1,11 @@ +SECTIONS +{ + . = 0x1000 + SIZEOF_HEADERS; + .text ALIGN (0x20) : + { + LONG (label - .) + label = .; + LONG (ADDR (.other)) + } + .other 0x2000 : {} +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/default-script.exp b/binutils-2.24/ld/testsuite/ld-scripts/default-script.exp new file mode 100644 index 0000000..2e6fce0 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/default-script.exp @@ -0,0 +1,34 @@ +# Test --default-script/-dT +# Copyright 2007, 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. + +set old_ldflags $LDFLAGS +if { [istarget spu*-*-*] } { + set LDFLAGS "$LDFLAGS --local-store 0:0" +} + +set test_list [lsort [glob -nocomplain $srcdir/$subdir/default-script*.d]] +foreach t $test_list { + # We need to strip the ".d", but can leave the dirname. + verbose [file rootname $t] + run_dump_test [file rootname $t] +} + +set LDFLAGS $old_ldflags diff --git a/binutils-2.24/ld/testsuite/ld-scripts/default-script.s b/binutils-2.24/ld/testsuite/ld-scripts/default-script.s new file mode 100644 index 0000000..78c474e --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/default-script.s @@ -0,0 +1,4 @@ + .text + .global text +text: + .long 0 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/default-script.t b/binutils-2.24/ld/testsuite/ld-scripts/default-script.t new file mode 100644 index 0000000..fc70187 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/default-script.t @@ -0,0 +1,7 @@ +_START = DEFINED(_START) ? _START : 0x9000000; +SECTIONS +{ + . = _START; + .text : {*(.text)} + /DISCARD/ : {*(*)} +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/default-script1.d b/binutils-2.24/ld/testsuite/ld-scripts/default-script1.d new file mode 100644 index 0000000..61973f7 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/default-script1.d @@ -0,0 +1,9 @@ +# source: default-script.s +# ld: -defsym _START=0x8000000 -T default-script.t +# nm: -n + +#... +0*8000000 . _START +#... +0*8000000 T text +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/default-script2.d b/binutils-2.24/ld/testsuite/ld-scripts/default-script2.d new file mode 100644 index 0000000..68ce2aa --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/default-script2.d @@ -0,0 +1,9 @@ +# source: default-script.s +# ld: -T default-script.t -defsym _START=0x8000000 +# nm: -n + +#... +0*8000000 . _START +#... +0*9000000 T text +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/default-script3.d b/binutils-2.24/ld/testsuite/ld-scripts/default-script3.d new file mode 100644 index 0000000..b2da496 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/default-script3.d @@ -0,0 +1,9 @@ +# source: default-script.s +# ld: -defsym _START=0x8000000 -dT default-script.t +# nm: -n + +#... +0*8000000 . _START +#... +0*8000000 T text +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/default-script4.d b/binutils-2.24/ld/testsuite/ld-scripts/default-script4.d new file mode 100644 index 0000000..0010084 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/default-script4.d @@ -0,0 +1,9 @@ +# source: default-script.s +# ld: --default-script default-script.t -defsym _START=0x8000000 +# nm: -n + +#... +0*8000000 . _START +#... +0*8000000 T text +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/defined.exp b/binutils-2.24/ld/testsuite/ld-scripts/defined.exp new file mode 100644 index 0000000..bfee102 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/defined.exp @@ -0,0 +1,73 @@ +# Test DEFINED in a linker script. +# By Ian Lance Taylor, Cygnus Support. +# Copyright 2001, 2003, 2005, 2006, 2007, 2010 +# 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. + +set testname "DEFINED" +set prms_id 5699 + +if ![ld_assemble $as $srcdir/$subdir/defined.s tmpdir/def.o] { + unresolved $testname + return +} + +global LDFLAGS +set saved_LDFLAGS "$LDFLAGS" +if [istarget "x86_64-*-mingw*"] then { + set LDFLAGS "$LDFLAGS --image-base 0" +} + +if ![ld_simple_link $ld tmpdir/def "$LDFLAGS -T $srcdir/$subdir/defined.t tmpdir/def.o"] { + fail $testname +} else { + if ![ld_nm $nm "" tmpdir/def] { + unresolved $testname + } else { + if {![info exists nm_output(value1)] \ + || ![info exists nm_output(value2)]} { + send_log "bad output from nm\n" + verbose "bad output from nm" + fail $testname + } else { + if {$nm_output(value1) != 1} { + send_log "value1 == $nm_output(value1)\n" + verbose "value1 == $nm_output(value1)" + fail $testname + } else { + if {$nm_output(value2) != 2} { + send_log "value2 == $nm_output(value2)\n" + verbose "value2 == $nm_output(value2)" + fail $testname + } else { + pass $testname + } + } + } + } +} + +set prms_id 0 +run_dump_test "defined2" +run_dump_test "defined3" +run_dump_test "defined4" +if ![is_aout_format] { + run_dump_test "defined5" +} +set LDFLAGS "$saved_LDFLAGS" diff --git a/binutils-2.24/ld/testsuite/ld-scripts/defined.s b/binutils-2.24/ld/testsuite/ld-scripts/defined.s new file mode 100644 index 0000000..243c397 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/defined.s @@ -0,0 +1,2 @@ + .globl defined + defined == 1 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/defined.t b/binutils-2.24/ld/testsuite/ld-scripts/defined.t new file mode 100644 index 0000000..c1ef1b6 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/defined.t @@ -0,0 +1,7 @@ +SECTIONS { + .text : { *(.text) } + .data : { *(.data) } + .bss : { *(.bss) *(COMMON) } +} +value1 = DEFINED (defined) ? 1 : 2; +value2 = DEFINED (undefined) ? 1 : 2; diff --git a/binutils-2.24/ld/testsuite/ld-scripts/defined2.d b/binutils-2.24/ld/testsuite/ld-scripts/defined2.d new file mode 100644 index 0000000..40728bd --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/defined2.d @@ -0,0 +1,22 @@ +#ld: -Tdefined2.t +#nm: -B +#source: phdrs.s +#xfail: "rs6000-*-aix*" + +# Check that arithmetic on DEFINED works. +# Matching both A and T accounts for formats that can't tell a .text +# symbol from an absolute symbol (mmo), but matches whatever section that +# contains an address matching the value. The symbol sym1 is supposed to +# be in the .text section for all targets, though. + +#... +0+1 [AT] defined1 +#... +0+11 A defined2 +#... +0+100 A defined3 +#... +0+1ff A defined4 +#... +0+3 T sym1 +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/defined2.t b/binutils-2.24/ld/testsuite/ld-scripts/defined2.t new file mode 100644 index 0000000..50ddad0 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/defined2.t @@ -0,0 +1,9 @@ +SECTIONS { + .text : { *(.text) sym1 = 3 - DEFINED (x); } + .data : { *(.data) } + .bss : { *(.bss) *(COMMON) } +} +defined1 = !DEFINED (x); +defined2 = DEFINED (defined1) + 16; +defined3 = DEFINED (defined2) * 256; +defined4 = 0x200 - DEFINED (defined3); diff --git a/binutils-2.24/ld/testsuite/ld-scripts/defined3.d b/binutils-2.24/ld/testsuite/ld-scripts/defined3.d new file mode 100644 index 0000000..61061b6 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/defined3.d @@ -0,0 +1,35 @@ +#ld: -Tdefined3.t +#nm: -B +#source: phdrs.s +#source: defined.s +#xfail: "rs6000-*-aix*" + +# Check that DEFINED matches only symbols defined before its location. +# The ellipsis account for target-specific symbols. Matching both A and T +# accounts for formats that can't tell a .text symbol from an absolute +# symbol (mmo), but matches whatever section that contains an address +# matching the value. + +#... +0+1 [AT] defined +#... +0+200 A defined1 +#... +0+201 A defined2 +#... +0+100 A defined3 +#... +0+ [AT] defined4 +#... +0+2a A defined5 +#... +0+ [AT] defined6 +#... +0+1 [AT] defined7 +#... +0+1 [AT] defined8 +#... +0+2a A sym1 +#... +[0-9a-f]+ T sym2 +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/defined3.t b/binutils-2.24/ld/testsuite/ld-scripts/defined3.t new file mode 100644 index 0000000..1fe6eef --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/defined3.t @@ -0,0 +1,15 @@ +defined6 = DEFINED (sym2) ? 1 : 0; +SECTIONS { + .text : { *(.text) sym2 = .; } + .data : { *(.data) } + .bss : { *(.bss) *(COMMON) } +} +defined4 = DEFINED (sym1) ? 1 : 0; +sym1 = 42; +defined3 = DEFINED (defined1) ? defined1 + 1 : 256; +defined1 = DEFINED (defined1) ? defined1 + 1 : 512; +defined2 = DEFINED (defined1) ? defined1 + 1 : 1024; +defined5 = DEFINED (sym1) ? sym1 : 0; +defined7 = DEFINED (sym2); +defined8 = !DEFINED (defined8); +defined = DEFINED (defined) ? defined : 42; diff --git a/binutils-2.24/ld/testsuite/ld-scripts/defined4.d b/binutils-2.24/ld/testsuite/ld-scripts/defined4.d new file mode 100644 index 0000000..b434e40 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/defined4.d @@ -0,0 +1,14 @@ +#ld: -Tdefined4.t +#nm: -B +#source: defined4.s +#xfail: rs6000-*-aix* +#notarget: mips*-*-* mmix-*-* +# We check that defined and defined1 have the same address. MIPS targets +# use different address. MMIX puts defined and defined1 in text section. + +# Check that arithmetic on DEFINED works. +#... +0+0 D defined +#... +0+0 D defined1 +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/defined4.s b/binutils-2.24/ld/testsuite/ld-scripts/defined4.s new file mode 100644 index 0000000..5969a44 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/defined4.s @@ -0,0 +1,4 @@ + .globl defined + .data +defined: + .word 0 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/defined4.t b/binutils-2.24/ld/testsuite/ld-scripts/defined4.t new file mode 100644 index 0000000..1221df2 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/defined4.t @@ -0,0 +1,6 @@ +SECTIONS { + .text : { *(.text) } + .data : { *(.data) } + .bss : { *(.bss) *(COMMON) } +} +defined1 = defined; diff --git a/binutils-2.24/ld/testsuite/ld-scripts/defined5.d b/binutils-2.24/ld/testsuite/ld-scripts/defined5.d new file mode 100644 index 0000000..3977c93 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/defined5.d @@ -0,0 +1,9 @@ +#ld: -Tdefined5.t +#nm: -B +#source: defined5.s +#xfail: rs6000-*-aix* + +# Check that arithmetic on DEFINED works. +#... +0+1000 D defined +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/defined5.s b/binutils-2.24/ld/testsuite/ld-scripts/defined5.s new file mode 100644 index 0000000..9dd58d6 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/defined5.s @@ -0,0 +1,6 @@ + .globl defined + .data + .byte 0 + .text +defined: + .byte 0 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/defined5.t b/binutils-2.24/ld/testsuite/ld-scripts/defined5.t new file mode 100644 index 0000000..04daf66 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/defined5.t @@ -0,0 +1,7 @@ +defined = addr1; +SECTIONS { + .text : { *(.text) } + . = ALIGN (0x1000); + .data : { *(.data) } + addr1 = ADDR (.data); +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/dynamic-sections-1.s b/binutils-2.24/ld/testsuite/ld-scripts/dynamic-sections-1.s new file mode 100644 index 0000000..9a72c96 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/dynamic-sections-1.s @@ -0,0 +1,2 @@ + .data + .4byte foo diff --git a/binutils-2.24/ld/testsuite/ld-scripts/dynamic-sections-2.s b/binutils-2.24/ld/testsuite/ld-scripts/dynamic-sections-2.s new file mode 100644 index 0000000..57cb02d --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/dynamic-sections-2.s @@ -0,0 +1,3 @@ + .data + .global foo +foo: .4byte 0 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/dynamic-sections.d b/binutils-2.24/ld/testsuite/ld-scripts/dynamic-sections.d new file mode 100644 index 0000000..279107d --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/dynamic-sections.d @@ -0,0 +1,6 @@ +# nm: -C +# ld: -T dynamic-sections.t +# name: dynamic sections +# source: dynamic-sections-1.s +# source: dynamic-sections-2.s +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/dynamic-sections.exp b/binutils-2.24/ld/testsuite/ld-scripts/dynamic-sections.exp new file mode 100644 index 0000000..b1b3ae7 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/dynamic-sections.exp @@ -0,0 +1,27 @@ +# Copyright 2007 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. + +# Check for bug introduced on 2002-06-10. See dynamic-sections.t for +# more details + +if ![is_elf_format] { + return +} + +run_dump_test dynamic-sections diff --git a/binutils-2.24/ld/testsuite/ld-scripts/dynamic-sections.t b/binutils-2.24/ld/testsuite/ld-scripts/dynamic-sections.t new file mode 100644 index 0000000..f1f24c8 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/dynamic-sections.t @@ -0,0 +1,11 @@ +SECTIONS +{ + .data : { *(.data) } + .rodata : { *(.rodata) } + + /* The .rel* sections are typically placed here, because of the way + elf32.em handles orphaned sections. A bug introduced on 2002-06-10 + would cause . to be 0 at this point. */ + + _bar = ASSERT (. > 0, "Bad . value"); +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-address-1.d b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-1.d new file mode 100644 index 0000000..f43e4c3 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-1.d @@ -0,0 +1,9 @@ +#ld: -T empty-address-1.t +#nm: -n +#notarget: frv-*-*linux* +#... +0+0 T _start +#... +0+2000000 [ADT] __data_end +0+2000000 [ADT] __data_start +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-address-1.s b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-1.s new file mode 100644 index 0000000..c5cc1a5 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-1.s @@ -0,0 +1,5 @@ + .text + .global _start +_start: + .long __data_start + .long __data_end diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-address-1.t b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-1.t new file mode 100644 index 0000000..57a8bed --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-1.t @@ -0,0 +1,11 @@ +SECTIONS +{ + .text 0x0000000: { *(.text) } + .data 0x2000000: + { + __data_start = . ; + *(.data) + } + __data_end = .; + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-address-2.s b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-2.s new file mode 100644 index 0000000..79f58ea --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-2.s @@ -0,0 +1,5 @@ + .text + .global _start +_start: + .long __data_end + .p2align 4 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-address-2a.d b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-2a.d new file mode 100644 index 0000000..5155041 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-2a.d @@ -0,0 +1,9 @@ +#source: empty-address-2.s +#ld: -Ttext 0x0000000 -Tdata 0x2000000 -T empty-address-2a.t +#nm: -n +#notarget: frv-*-*linux* *-*-linux*aout *-*-linux*oldld +#... +0+0 T _start +#... +0+10 [ADT] __data_end +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-address-2a.t b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-2a.t new file mode 100644 index 0000000..6a40ad8 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-2a.t @@ -0,0 +1,7 @@ +SECTIONS +{ + .text : { *(.text) } + .data : { *(.data) } + __data_end = .; + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-address-2b.d b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-2b.d new file mode 100644 index 0000000..22f6e26 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-2b.d @@ -0,0 +1,9 @@ +#source: empty-address-2.s +#ld: -Ttext 0x0000000 -Tdata 0x2000000 -T empty-address-2b.t +#nm: -n +#notarget: frv-*-*linux* *-*-linux*aout *-*-linux*oldld +#... +0+0 T _start +#... +0+10 [ADT] __data_end +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-address-2b.t b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-2b.t new file mode 100644 index 0000000..dcf264f --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-2b.t @@ -0,0 +1,11 @@ +SECTIONS +{ + .text 0x0000000: { *(.text) } + .data : + { + PROVIDE (__data_start = .); + *(.data) + } + __data_end = .; + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-address-3.s b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-3.s new file mode 100644 index 0000000..6b07dd4 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-3.s @@ -0,0 +1,5 @@ + .text + .global _start +_start: + .byte 0,0,0,0,0,0,0,0 + .byte 0,0,0,0,0,0,0,0 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-address-3a.d b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-3a.d new file mode 100644 index 0000000..68d1663 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-3a.d @@ -0,0 +1,9 @@ +#source: empty-address-3.s +#ld: -T empty-address-3a.t +#nm: -n +#notarget: mmix-knuth-mmixware +#... +0+0 T _start +#... +0+10 [DT] __data_end +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-address-3a.t b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-3a.t new file mode 100644 index 0000000..2807e71 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-3a.t @@ -0,0 +1,10 @@ +SECTIONS +{ + .text 0x00000000: { *(.text) } + .data ALIGN(0x1000) + (. & (0x1000 - 1)): + { + *(.data) + } + __data_end = .; + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-address-3b.d b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-3b.d new file mode 100644 index 0000000..d3ebee3 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-3b.d @@ -0,0 +1,9 @@ +#source: empty-address-3.s +#ld: -T empty-address-3b.t +#nm: -n +#notarget: mmix-knuth-mmixware +#... +0+0 T _start +#... +0+10 [DT] __data_end +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-address-3b.t b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-3b.t new file mode 100644 index 0000000..4f213af --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-3b.t @@ -0,0 +1,11 @@ +SECTIONS +{ + .text 0x00000000: { *(.text) } + .data ALIGN(0x1000) + (. & (0x1000 - 1)): + { + PROVIDE (__data_start = .); + *(.data) + } + __data_end = .; + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-address-3c.d b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-3c.d new file mode 100644 index 0000000..7fac2f6 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-3c.d @@ -0,0 +1,10 @@ +#source: empty-address-3.s +#ld: -T empty-address-3c.t +#nm: -n +#... +0+0 T _start +#... +0+1010 [ADT] __data_end +#... +0+1010 [ADT] __data_start +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-address-3c.t b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-3c.t new file mode 100644 index 0000000..6de5198 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-address-3c.t @@ -0,0 +1,11 @@ +SECTIONS +{ + .text 0x00000000: { *(.text) } + .data ALIGN(0x1000) + (. & (0x1000 - 1)): + { + __data_start = .; + *(.data) + } + __data_end = .; + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-address.exp b/binutils-2.24/ld/testsuite/ld-scripts/empty-address.exp new file mode 100644 index 0000000..6a2150f --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-address.exp @@ -0,0 +1,32 @@ +# Make sure that "dot" is updated for empty sections if their addresses +# are set. +# Copyright 2006, 2007, 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. + +if [istarget "x86_64-*-mingw*"] then { + set LDFLAGS "$LDFLAGS --image-base 0" +} + +run_dump_test empty-address-1 +run_dump_test empty-address-2a +run_dump_test empty-address-2b +run_dump_test empty-address-3a +run_dump_test empty-address-3b +run_dump_test empty-address-3c diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-aligned.d b/binutils-2.24/ld/testsuite/ld-scripts/empty-aligned.d new file mode 100644 index 0000000..d9916dd --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-aligned.d @@ -0,0 +1,14 @@ +#source: empty-aligned.s +#ld: -T empty-aligned.t +#readelf: -l --wide +#xfail: "hppa64-*-*" +#notarget: frv-*-*linux* + +#... +Program Headers: + +Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg +Align + +LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ [RWE ]+ +0x[0-9a-f]+ +! +LOAD .* +#... + +Segment Sections\.\.\. + +00 +.text diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-aligned.exp b/binutils-2.24/ld/testsuite/ld-scripts/empty-aligned.exp new file mode 100644 index 0000000..70da61d --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-aligned.exp @@ -0,0 +1,29 @@ +# Make sure empty aligned sections do not change output layout. +# Copyright 2005, 2007 +# 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 +} + +set testname "empty-aligned" + +run_dump_test empty-aligned diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-aligned.s b/binutils-2.24/ld/testsuite/ld-scripts/empty-aligned.s new file mode 100644 index 0000000..2079aa7 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-aligned.s @@ -0,0 +1,2 @@ + .text + .long 123 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-aligned.t b/binutils-2.24/ld/testsuite/ld-scripts/empty-aligned.t new file mode 100644 index 0000000..e59bc20 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-aligned.t @@ -0,0 +1,29 @@ +SECTIONS +{ + .text : { *(.text) } + /* Alignment at beginning shouldn't result in empty section being kept. */ + .text1 ALIGN (4096) : + { + *(.text1) + } + /* Same for alignment at beginning and end. */ + .text2 ALIGN (4096) : + { + *(.text2) + . = ALIGN (4096); + } + /* Same for alignment just at end, although we need to be careful in + the expression used to align. */ + .text3 : + { + *(.text3) + . = ALIGN (. != 0 ? 4096 : 1); + } + /* Same when setting vma and lma. This also shouldn't result in + .text3 being kept. */ + .text4 ADDR (.text3) + SIZEOF (.text3) + 8192 : AT (LOADADDR (.text3)) + { + *(.text4) + } + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-orphan.d b/binutils-2.24/ld/testsuite/ld-scripts/empty-orphan.d new file mode 100644 index 0000000..7bd9b9a --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-orphan.d @@ -0,0 +1,6 @@ +#source: empty-orphan.s +#ld: -T empty-orphan.t +#readelf: -l --wide +#... + +LOAD +[x0-9a-f]+ [x0]+70000000 [x0]+70000000 [x0]+(2|4|8|10|20|40|80) .* +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-orphan.exp b/binutils-2.24/ld/testsuite/ld-scripts/empty-orphan.exp new file mode 100644 index 0000000..0c6ebd7 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-orphan.exp @@ -0,0 +1,37 @@ +# Make sure orphan sections do not lead to huge output files. +# By David Heine, Tensilica, Inc. +# Copyright 2005, 2006, 2007, 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 +} + +set old_ldflags $LDFLAGS +if { [istarget spu*-*-*] } { + set LDFLAGS "$LDFLAGS --local-store 0:0" +} + +set testname "empty-orphan" + +run_dump_test empty-orphan + +set LDFLAGS $old_ldflags diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-orphan.s b/binutils-2.24/ld/testsuite/ld-scripts/empty-orphan.s new file mode 100644 index 0000000..c8fe675 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-orphan.s @@ -0,0 +1,4 @@ + .section .orphan_data, "a" + # empty but defined + .section .data + .word 0x1111 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/empty-orphan.t b/binutils-2.24/ld/testsuite/ld-scripts/empty-orphan.t new file mode 100644 index 0000000..b57e164 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/empty-orphan.t @@ -0,0 +1,22 @@ +MEMORY +{ + default_mem : ORIGIN = 0x0, LENGTH = 0x100000 + text_mem : ORIGIN = 0x60000000, LENGTH = 0x100 + data_mem : ORIGIN = 0x70000000, LENGTH = 0x100 +} + +PHDRS +{ + default_phdr PT_LOAD; + text_phdr PT_LOAD; + data_phdr PT_LOAD; +} + +SECTIONS +{ + .text : { *(.text) } > text_mem : text_phdr + .data : { *(.data) } > data_mem : data_phdr + .bss : { *(.bss) } > data_mem : data_phdr + /DISCARD/ : { *(.reginfo) *(.glue*) } + /* .orphan_data is an orphan */ +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/expr.exp b/binutils-2.24/ld/testsuite/ld-scripts/expr.exp new file mode 100644 index 0000000..0f92d97 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/expr.exp @@ -0,0 +1,27 @@ +# Test expressions in a linker script. +# By Nathan Sidwell, CodeSourcery LLC +# Copyright 2006, 2007, 2010 +# 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. + +run_dump_test expr1 +run_dump_test expr2 +run_dump_test sane1 +run_dump_test assign-loc +run_dump_test pr14962 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/expr1.d b/binutils-2.24/ld/testsuite/ld-scripts/expr1.d new file mode 100644 index 0000000..d96dfc1 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/expr1.d @@ -0,0 +1,2 @@ +# ld: -T expr1.t +# error: undefined section .* in expression diff --git a/binutils-2.24/ld/testsuite/ld-scripts/expr1.s b/binutils-2.24/ld/testsuite/ld-scripts/expr1.s new file mode 100644 index 0000000..ec0ce90 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/expr1.s @@ -0,0 +1,2 @@ + .word 0 + diff --git a/binutils-2.24/ld/testsuite/ld-scripts/expr1.t b/binutils-2.24/ld/testsuite/ld-scripts/expr1.t new file mode 100644 index 0000000..e0810ba --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/expr1.t @@ -0,0 +1,12 @@ +ENTRY(RAM) + +MEMORY +{ + ram (rwx) : ORIGIN = 0, LENGTH = 0x1000000 +} + +SECTIONS +{ +.text : { } >ram +} +RAM = ADDR(ram); diff --git a/binutils-2.24/ld/testsuite/ld-scripts/expr2.d b/binutils-2.24/ld/testsuite/ld-scripts/expr2.d new file mode 100644 index 0000000..26354f6 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/expr2.d @@ -0,0 +1,7 @@ +# ld: -T expr2.t +#nm: -B +#xfail: rs6000-*-aix* arm-*-*aout + +#... +.* D defined +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/expr2.s b/binutils-2.24/ld/testsuite/ld-scripts/expr2.s new file mode 100644 index 0000000..5969a44 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/expr2.s @@ -0,0 +1,4 @@ + .globl defined + .data +defined: + .word 0 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/expr2.t b/binutils-2.24/ld/testsuite/ld-scripts/expr2.t new file mode 100644 index 0000000..634eab2 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/expr2.t @@ -0,0 +1,11 @@ +SECTIONS +{ + . = 0xc000; + .text : + { + _text = .; + *(.text) + } + _end = .; +} +ASSERT (_end - _text <= 0x100, "fail"); diff --git a/binutils-2.24/ld/testsuite/ld-scripts/extern.exp b/binutils-2.24/ld/testsuite/ld-scripts/extern.exp new file mode 100644 index 0000000..f05cd35 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/extern.exp @@ -0,0 +1,71 @@ +# Test EXTERN in a linker script. +# By Nathan Sidwell, CodeSourcery LLC +# Copyright 2007 +# 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. + +set testname "EXTERN" + +if ![ld_assemble $as $srcdir/$subdir/extern.s tmpdir/extern.o] { + unresolved $testname + return +} + +if ![ld_simple_link $ld tmpdir/extern "-T $srcdir/$subdir/extern.t tmpdir/extern.o"] { + fail $testname +} + +if ![ld_nm $nm "" tmpdir/extern] { + unresolved $testname + return +} + +if {![info exists nm_output(sym1)] || $nm_output(sym1) != 1} { + send_log "sym1 wrong\n" + verbose "sym1 wrong" + fail $testname + return +} + +if {![info exists nm_output(sym2)] || $nm_output(sym2) != 2} { + send_log "sym1 wrong\n" + verbose "sym1 wrong" + fail $testname + return +} +if {![info exists nm_output(sym3)] || $nm_output(sym3) != 3} { + send_log "sym1 wrong\n" + verbose "sym1 wrong" + fail $testname + return +} +if {![info exists nm_output(sym4)] || $nm_output(sym4) != 4} { + send_log "sym1 wrong\n" + verbose "sym1 wrong" + fail $testname + return +} +if {![info exists nm_output(sym5)] || $nm_output(sym5) != 5} { + send_log "sym1 wrong\n" + verbose "sym1 wrong" + fail $testname + return +} + +pass $testname diff --git a/binutils-2.24/ld/testsuite/ld-scripts/extern.s b/binutils-2.24/ld/testsuite/ld-scripts/extern.s new file mode 100644 index 0000000..09cc1e1 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/extern.s @@ -0,0 +1 @@ + .text diff --git a/binutils-2.24/ld/testsuite/ld-scripts/extern.t b/binutils-2.24/ld/testsuite/ld-scripts/extern.t new file mode 100644 index 0000000..b2a012a --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/extern.t @@ -0,0 +1,14 @@ + +EXTERN(sym1) +EXTERN(sym2, sym3) +EXTERN(sym4 sym5) + +PROVIDE(sym1 = 1); +PROVIDE(sym2 = 2); +PROVIDE(sym3 = 3); +PROVIDE(sym4 = 4); +PROVIDE(sym5 = 5); + +SECTIONS +{ +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/include-1.d b/binutils-2.24/ld/testsuite/ld-scripts/include-1.d new file mode 100644 index 0000000..4ad1fe8 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/include-1.d @@ -0,0 +1,13 @@ +# name: include-1 +# source: include.s +# ld: -T include-1.t +# objdump: -w -h +# xfail: "*-aix*" +# AIX targets rename the .text and .data sectons... + +.*: file format .* + +Sections: +Idx +Name +Size +VMA +LMA +File off +Algn +Flags + 0 .text 0+0000020 0+0000000 0+0000000 [0-9a-f]+ 2\*\*[0-9]+ CONTENTS, ALLOC, LOAD,.*CODE + 1 .data 0+0000010 0+0100000 0+0100000 [0-9a-f]+ 2\*\*[0-9]+ CONTENTS, ALLOC, LOAD, DATA diff --git a/binutils-2.24/ld/testsuite/ld-scripts/include-1.t b/binutils-2.24/ld/testsuite/ld-scripts/include-1.t new file mode 100644 index 0000000..cf2f8cd --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/include-1.t @@ -0,0 +1,4 @@ + +INCLUDE include-mem.t +_start = 0x1000; +INCLUDE include-sections.t diff --git a/binutils-2.24/ld/testsuite/ld-scripts/include-data.t b/binutils-2.24/ld/testsuite/ld-scripts/include-data.t new file mode 100644 index 0000000..eddbbb3 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/include-data.t @@ -0,0 +1,4 @@ +.data : { +INCLUDE include-subdata.t +__end = .; +}>ram diff --git a/binutils-2.24/ld/testsuite/ld-scripts/include-mem.t b/binutils-2.24/ld/testsuite/ld-scripts/include-mem.t new file mode 100644 index 0000000..8aa65b1 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/include-mem.t @@ -0,0 +1,5 @@ + +MEMORY { + rom (rwx) : ORIGIN = 0, LENGTH = 0x1000 + INCLUDE include-ram.t +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/include-ram.t b/binutils-2.24/ld/testsuite/ld-scripts/include-ram.t new file mode 100644 index 0000000..f7eaf0e --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/include-ram.t @@ -0,0 +1 @@ +ram (rw) : ORIGIN = 0x100000, LENGTH = 512 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/include-sections.t b/binutils-2.24/ld/testsuite/ld-scripts/include-sections.t new file mode 100644 index 0000000..5d6ca1e --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/include-sections.t @@ -0,0 +1,5 @@ +SECTIONS { + .text : { *(.text) } >rom + INCLUDE include-data.t + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/include-subdata.t b/binutils-2.24/ld/testsuite/ld-scripts/include-subdata.t new file mode 100644 index 0000000..136c9f4 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/include-subdata.t @@ -0,0 +1,2 @@ + *(.data) + diff --git a/binutils-2.24/ld/testsuite/ld-scripts/include.exp b/binutils-2.24/ld/testsuite/ld-scripts/include.exp new file mode 100644 index 0000000..08fa1b6 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/include.exp @@ -0,0 +1,40 @@ +# Test for proper diagnosis of overflowed memory regions. +# Copyright 2008, 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. + +load_lib ld-lib.exp + +if [is_aout_format] { + return +} + +set old_ldflags $LDFLAGS +if { [istarget spu*-*-*] } { + set LDFLAGS "$LDFLAGS --local-store 0:0 --no-overlays" +} + +set test_list [lsort [glob -nocomplain $srcdir/$subdir/include*.d]] +foreach test_file $test_list { + set test_name [file rootname $test_file] + set map_file "tmpdir/[file tail $test_name].map" + verbose $test_name + run_dump_test $test_name +} + +set LDFLAGS $old_ldflags diff --git a/binutils-2.24/ld/testsuite/ld-scripts/include.s b/binutils-2.24/ld/testsuite/ld-scripts/include.s new file mode 100644 index 0000000..e9fca05 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/include.s @@ -0,0 +1,5 @@ + .text + .fill 32,1,0x12 + + .data + .fill 16,1,0x34 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/log2.exp b/binutils-2.24/ld/testsuite/ld-scripts/log2.exp new file mode 100644 index 0000000..43827dc --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/log2.exp @@ -0,0 +1,34 @@ +# Test LOG2() expression in linker script language. +# By Clemens Lang +# Copyright 2013 +# 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. + +set testname "binary logarithm" + +if {![ld_assemble $as $srcdir/$subdir/log2.s tmpdir/log2.o]} { + unresolved $testname + return +} + +if {![ld_simple_link $ld tmpdir/log2 "-T $srcdir/$subdir/log2.t tmpdir/log2.o"]} { + fail $testname +} else { + pass $testname +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/log2.s b/binutils-2.24/ld/testsuite/ld-scripts/log2.s new file mode 100644 index 0000000..f3f74ab --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/log2.s @@ -0,0 +1 @@ + .word 0 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/log2.t b/binutils-2.24/ld/testsuite/ld-scripts/log2.t new file mode 100644 index 0000000..abf73a9 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/log2.t @@ -0,0 +1,8 @@ +ASSERT(LOG2CEIL(0) == 0, "LOG2CEIL(0) == 0"); +ASSERT(LOG2CEIL(1) == 0, "LOG2CEIL(1) == 0"); +ASSERT(LOG2CEIL(2) == 1, "LOG2CEIL(2) == 1"); +ASSERT(LOG2CEIL(3) == 2, "LOG2CEIL(3) == 2"); +ASSERT(LOG2CEIL(4) == 2, "LOG2CEIL(4) == 2"); +ASSERT(LOG2CEIL(0x0ff) == 8, "LOG2CEIL(0x0ff) == 8"); +ASSERT(LOG2CEIL(0x100) == 8, "LOG2CEIL(0x100) == 8"); +ASSERT(LOG2CEIL(0x1ff) == 9, "LOG2CEIL(0x1ff) == 9"); diff --git a/binutils-2.24/ld/testsuite/ld-scripts/map-address.d b/binutils-2.24/ld/testsuite/ld-scripts/map-address.d new file mode 100644 index 0000000..7877ca4 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/map-address.d @@ -0,0 +1,12 @@ +#... +Linker script and memory map +#... + *0x0*000020 *def1 = .* + *0x0*000020 *def2 = def1 + *0x0*010001 *\. = 0x10001 + *0x0*010001 *foo = \. + *0x0*010201 *\. = \(\. \+ 0x200\) + *0x0*010201 *bar = \. + *0x0*010204 *\. = ALIGN \(0x4\) + *0x0*010204 *frob = \. +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/map-address.exp b/binutils-2.24/ld/testsuite/ld-scripts/map-address.exp new file mode 100644 index 0000000..499a824 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/map-address.exp @@ -0,0 +1,47 @@ +# Test address printed by --print-map +# Copyright 2002, 2005, 2007 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. + +set testname "map addresses" + +# The source file doesn't matter. Pinch one from the sizeof test. +if {![ld_assemble $as $srcdir/$subdir/sizeof.s tmpdir/map-address.o]} { + unresolved $testname + return +} + +if {![ld_simple_link $ld tmpdir/map-address \ + "-T $srcdir/$subdir/map-address.t \ + tmpdir/map-address.o \ + -Map tmpdir/map-address.map"]} { + fail $testname + return +} + +if [is_remote host] then { + remote_upload host "tmpdir/map_address.map" +} + +if {[regexp_diff \ + "tmpdir/map-address.map" \ + "$srcdir/$subdir/map-address.d"]} { + fail $testname +} else { + pass $testname +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/map-address.t b/binutils-2.24/ld/testsuite/ld-scripts/map-address.t new file mode 100644 index 0000000..e077ed1 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/map-address.t @@ -0,0 +1,11 @@ +SECTIONS +{ + def1 = DEFINED(foo) ? 0x10 : 0x20; + def2 = def1; + . = 0x10001; + foo = .; + . += 0x200; + bar = .; + . = ALIGN (4); + frob = .; +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/memory.t b/binutils-2.24/ld/testsuite/ld-scripts/memory.t new file mode 100644 index 0000000..129bd7c --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/memory.t @@ -0,0 +1,33 @@ +MEMORY +{ + R_TEXTMEM (ARX) : ORIGIN = 0x100, LENGTH = 32K + R_DATAMEM (AW) : org = 0x1000, l = (64 * 1024) +} + +REGION_ALIAS ("A_TEXTMEM", R_TEXTMEM); +REGION_ALIAS ("A_DATAMEM", R_DATAMEM); + +REGION_ALIAS ("TEXTMEM", A_TEXTMEM); +REGION_ALIAS ("DATAMEM", A_DATAMEM); + +SECTIONS +{ + . = 0; + .text : + { + text_start = ORIGIN (TEXTMEM); + *(.text) + *(.pr) + text_end = .; + } > TEXTMEM + + data_start = ORIGIN (DATAMEM); + .data : + { + *(.data) + *(.rw) + data_end = .; + } >DATAMEM + + fred = ORIGIN(DATAMEM) + LENGTH(DATAMEM); +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/overlay-size-map.d b/binutils-2.24/ld/testsuite/ld-scripts/overlay-size-map.d new file mode 100644 index 0000000..a72d359 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/overlay-size-map.d @@ -0,0 +1,29 @@ +#... +\.bss1 *0x0*20000 *0x10 +#... +\.bss2 *0x0*20000 *0x30 load address 0x0*20010 +#... +\.bss3 *0x0*20000 *0x20 load address 0x0*20040 +#... +.*0x0+020030[ ]*end_of_bss_overlays.* +#... +\.mtext *0x0*10000 *0x20 load address 0x0*30000 +#... +\.mbss *0x0*20030 *0x230 load address 0x0*20060 +#... +\.text1 *0x0*10020 *0x80 load address 0x0*30020 +#... +\.text2 *0x0*10020 *0x40 load address 0x0*300a0 +#... +\.text3 *0x0*10020 *0x20 load address 0x0*300e0 +#... +.*0x0+0100a0[ ]*end_of_text_overlays.* +#... +\.data1 *0x0*20260 *0x30 load address 0x0*30100 +#... +\.data2 *0x0*20260 *0x40 load address 0x0*30130 +#... +\.data3 *0x0*20260 *0x50 load address 0x0*30170 +#... +.*0x0+0202b0[ ]*end_of_data_overlays.* +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/overlay-size.d b/binutils-2.24/ld/testsuite/ld-scripts/overlay-size.d new file mode 100644 index 0000000..78a9c92 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/overlay-size.d @@ -0,0 +1,32 @@ +# ld: -T overlay-size.t -Map tmpdir/overlay-size.map +# name: overlay size +# objdump: --headers +# xfail: rx-*-* +# FAILS on the RX because the linker has to set LMA == VMA for the +# Renesas loader. +# +# The .bss[123] LMAs are deliberately blanked out. We can't +# reliably map overlaid sections to segments. +#... + .. \.bss1 +0+010 +0+20000 .* +#... + .. \.bss2 +0+030 +0+20000 .* +#... + .. \.bss3 +0+020 +0+20000 .* +#... + .. \.mtext +0+020 +0+10000 +0+30000 .* +#... + .. \.mbss +0+230 +0+20030 .* +#... + .. \.text1 +0+080 +0+10020 +0+30020 .* +#... + .. \.text2 +0+040 +0+10020 +0+300a0 .* +#... + .. \.text3 +0+020 +0+10020 +0+300e0 .* +#... + .. \.data1 +0+030 +0+20260 +0+30100 .* +#... + .. \.data2 +0+040 +0+20260 +0+30130 .* +#... + .. \.data3 +0+050 +0+20260 +0+30170 .* +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/overlay-size.exp b/binutils-2.24/ld/testsuite/ld-scripts/overlay-size.exp new file mode 100644 index 0000000..42c4348 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/overlay-size.exp @@ -0,0 +1,34 @@ +# Test the OVERLAY statement. +# Copyright 2002, 2005, 2007 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. + +if ![is_elf_format] { + return +} + +run_dump_test overlay-size + +set testname "overlay size (map check)" + +if [regexp_diff "tmpdir/overlay-size.map" \ + "$srcdir/$subdir/overlay-size-map.d"] { + fail $testname +} else { + pass $testname +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/overlay-size.s b/binutils-2.24/ld/testsuite/ld-scripts/overlay-size.s new file mode 100644 index 0000000..5428c97 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/overlay-size.s @@ -0,0 +1,25 @@ + .section .bss1, "aw", "nobits" + .space 0x10 + .section .bss2, "aw", "nobits" + .space 0x30 + .section .bss3, "aw", "nobits" + .space 0x20 + + .section .text1, "ax", "progbits" + .space 0x80 + .section .text2, "ax", "progbits" + .space 0x40 + .section .text3, "ax", "progbits" + .space 0x20 + + .section .data1, "aw", "progbits" + .space 0x30 + .section .data2, "aw", "progbits" + .space 0x40 + .section .data3, "aw", "progbits" + .space 0x50 + + .section .mtext, "ax", "progbits" + .space 0x20 + .section .mbss, "aw", "nobits" + .space 0x30 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/overlay-size.t b/binutils-2.24/ld/testsuite/ld-scripts/overlay-size.t new file mode 100644 index 0000000..0d9af35 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/overlay-size.t @@ -0,0 +1,64 @@ +MEMORY +{ + TEXTMEM (ARX) : ORIGIN = 0x10000, LENGTH = 32K + DATAMEM (AW) : ORIGIN = 0x20000, LENGTH = 32K + LOADMEM (AW) : ORIGIN = 0x30000, LENGTH = 32K +} + +/* Map should be: + + SIZE VMA LMA + .bss1 10 20000 20000 + .bss2 30 20000 20010 + .bss3 20 20000 20040 + .mbss 230 20030 20060 + + .mtext 20 10000 30000 + .text1 80 10020 30020 + .text2 40 10020 300a0 + .text3 20 10020 300e0 + + .data1 30 20260 30100 + .data2 40 20260 30130 + .data3 50 20260 30170 */ + +SECTIONS +{ + OVERLAY : + { + .bss1 { *(.bss1) } + .bss2 { *(.bss2) } + .bss3 { *(.bss3) } + } > DATAMEM + + end_of_bss_overlays = . ; + + .mtext : { *(.mtext) } > TEXTMEM AT > LOADMEM + + .mbss : AT (__load_stop_bss3) + { + *(.mbss) + . += 0x200; + } > DATAMEM + + OVERLAY : + { + .text1 { *(.text1) } + .text2 { *(.text2) } + .text3 { *(.text3) } + } > TEXTMEM AT > LOADMEM + + end_of_text_overlays = . ; + + OVERLAY : + { + .data1 { *(.data1) } + .data2 { *(.data2) } + .data3 { *(.data3) } + } > DATAMEM AT > LOADMEM + + end_of_data_overlays = . ; + + . = 0x8000; + /DISCARD/ : { *(.reginfo) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/phdrs.exp b/binutils-2.24/ld/testsuite/ld-scripts/phdrs.exp new file mode 100644 index 0000000..b7f3682 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/phdrs.exp @@ -0,0 +1,76 @@ +# Test PHDRS in a linker script. +# By Ian Lance Taylor, Cygnus Support. +# Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007 +# 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 +} + +# This is a very simplistic test. + +set testname "PHDRS" + +set ldopt "" +if { [istarget spu*-*-*] } { + set ldopt "--local-store 0:0" +} + +if ![ld_assemble $as $srcdir/$subdir/phdrs.s tmpdir/phdrs.o] { + unresolved $testname + return +} + +set phdrs_regexp \ +".*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-.*" + +# On a 64 bit ELF format, we need different numbers. +if [is_elf64 tmpdir/phdrs.o] { + set phdrs_regexp \ +".*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-.*" +} + +set ldopt "$ldopt -T $srcdir/$subdir/phdrs.t tmpdir/phdrs.o" +if ![ld_simple_link $ld tmpdir/phdrs $ldopt] { + fail $testname +} else { + if {![is_remote host] && [which $objdump] == 0} { + unresolved $testname + return + } + set exec_output [run_host_cmd "$objdump" "--private-headers tmpdir/phdrs"] + set exec_output [prune_warnings $exec_output] + verbose -log $exec_output + + # The RX port sets the p_paddr of loadable segments to 0 in order + # to be compatible with Renesas tools. When an RX executable is + # loaded into a BFD based tool the code tries to reconstruct the + # correct vaddr and paddr values. This is not always possible + # however and this test is one example of where the reconstruction + # fails. + setup_xfail rx-*-* + + if [regexp $phdrs_regexp $exec_output] { + pass $testname + } else { + fail $testname + } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/phdrs.s b/binutils-2.24/ld/testsuite/ld-scripts/phdrs.s new file mode 100644 index 0000000..ec1f0d1 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/phdrs.s @@ -0,0 +1,8 @@ + .text + + .long 1 + + .data + + .long 2 + diff --git a/binutils-2.24/ld/testsuite/ld-scripts/phdrs.t b/binutils-2.24/ld/testsuite/ld-scripts/phdrs.t new file mode 100644 index 0000000..283e30c --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/phdrs.t @@ -0,0 +1,16 @@ +PHDRS +{ + header PT_PHDR PHDRS ; + text PT_LOAD FILEHDR PHDRS ; + data PT_LOAD ; +} + +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/ : { *(.*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/phdrs2.exp b/binutils-2.24/ld/testsuite/ld-scripts/phdrs2.exp new file mode 100644 index 0000000..b680d85 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/phdrs2.exp @@ -0,0 +1,75 @@ +# Test PHDRS with empty sections in a linker script. +# Copyright 2006, 2005, 2007, 2010 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. + +# PHDRS2 is only meaningful for ELF. +if { ![istarget *-*-sysv4*] \ + && ![istarget *-*-unixware*] \ + && ![istarget *-*-elf*] \ + && ![istarget *-*-eabi*] \ + && ![istarget hppa*64*-*-hpux*] \ + && ![istarget *-*-linux*] \ + && ![istarget *-*-gnu*] \ + && ![istarget *-*-irix5*] \ + && ![istarget *-*-irix6*] \ + && ![istarget *-*-solaris2*] } { + return +} + +if { [istarget *-*-linux*aout*] \ + || [istarget *-*-linux*oldld*] } { + return +} + +# This is a very simplistic test. + +set testname "PHDRS2" + +set ldopt "" +if { [istarget spu*-*-*] } { + set ldopt "--local-store 0:0" +} + +if ![ld_assemble $as $srcdir/$subdir/phdrs2.s tmpdir/phdrs2.o] { + unresolved $testname + return +} + +set phdrs_regexp \ + ".*Program Header:.*LOAD *off *0x00\[0-9a-f\]* *vaddr *0x00*800000 *paddr *0x00*800000.*filesz *0x0\[0-9a-f\]* *memsz *0x0\[0-9a-f\]*.*LOAD *off *0x00\[0-9a-f\]* *vaddr *0x00*800004 *paddr *0x00*800004.*filesz *0x00*\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* *flags rw.*" + +set ldopt "$ldopt -T $srcdir/$subdir/phdrs2.t tmpdir/phdrs2.o" +if ![ld_simple_link $ld tmpdir/phdrs2 $ldopt] { + fail $testname +} else { + if {![is_remote host] && [which $objdump] == 0} { + unresolved $testname + return + } + + set exec_output [run_host_cmd "$objdump" "--private-headers tmpdir/phdrs2"] + set exec_output [prune_warnings $exec_output] + verbose -log $exec_output + + if [regexp $phdrs_regexp $exec_output] { + pass $testname + } else { + fail $testname + } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/phdrs2.s b/binutils-2.24/ld/testsuite/ld-scripts/phdrs2.s new file mode 100644 index 0000000..1e29ddc --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/phdrs2.s @@ -0,0 +1,7 @@ + .section .foo, "ax" + .p2align 2 + .long 1 + + .section .bar, "aw" + .p2align 2 + .long 2 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/phdrs2.t b/binutils-2.24/ld/testsuite/ld-scripts/phdrs2.t new file mode 100644 index 0000000..bccbcec --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/phdrs2.t @@ -0,0 +1,23 @@ +PHDRS +{ + Foo PT_LOAD ; + Bar PT_LOAD ; +} + +SECTIONS +{ + . = 0x800000 - 1; + /* The PHDRS generated should start at the aligned .foo section + address, not the unaligned .empty section address */ + .empty : { + EMPTY_START = ABSOLUTE(.) ; + *(.empty) + EMPTY_END = ABSOLUTE(.) ; + } : Foo + .foo : { *(.foo) } : Foo + .bar : { *(.bar) + LONG(EMPTY_START) ; + } : Bar + + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/phdrs3.d b/binutils-2.24/ld/testsuite/ld-scripts/phdrs3.d new file mode 100644 index 0000000..7b37d80 --- /dev/null +++ b/binutils-2.24/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.* diff --git a/binutils-2.24/ld/testsuite/ld-scripts/phdrs3.exp b/binutils-2.24/ld/testsuite/ld-scripts/phdrs3.exp new file mode 100644 index 0000000..9ab8363 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/phdrs3.exp @@ -0,0 +1,39 @@ +# Test PHDRS in a linker script. +# By Nathan Sidwell <nathan@codesourcery.com> +# 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 --local-store 0:0" +} + +run_dump_test "phdrs3" +run_dump_test "phdrs3a" + +set LDFLAGS $old_ldflags diff --git a/binutils-2.24/ld/testsuite/ld-scripts/phdrs3.t b/binutils-2.24/ld/testsuite/ld-scripts/phdrs3.t new file mode 100644 index 0000000..4bd4e85 --- /dev/null +++ b/binutils-2.24/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/ : { *(.*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/phdrs3a.d b/binutils-2.24/ld/testsuite/ld-scripts/phdrs3a.d new file mode 100644 index 0000000..80bde71 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/phdrs3a.d @@ -0,0 +1,9 @@ +#name: PHDRS headers 3a +#source: phdrs.s +#ld: -T phdrs3a.t +#readelf: -l --wide + +#... +[ \t]+LOAD[ x0-9a-f]+ R [ x0-9a-f]+ +[ \t]+LOAD[ x0-9a-f]+ E [ x0-9a-f]+ +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/phdrs3a.t b/binutils-2.24/ld/testsuite/ld-scripts/phdrs3a.t new file mode 100644 index 0000000..c07ff34 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/phdrs3a.t @@ -0,0 +1,15 @@ +PHDRS +{ + data PT_LOAD FILEHDR PHDRS FLAGS(4); + text PT_LOAD FILEHDR PHDRS FLAGS(1); +} + +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/ : { *(.*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/pr14962.d b/binutils-2.24/ld/testsuite/ld-scripts/pr14962.d new file mode 100644 index 0000000..06b223e --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/pr14962.d @@ -0,0 +1,11 @@ +#ld: -Ttext=0x1000 -Tdata=0x2000 -T pr14962.t +#source: pr14962a.s +#source: pr14962b.s +#nm: -n +#notarget: rx-*-* mmix-knuth-mmixware +# The reference to x would normally generate a cross-reference error +# but the linker script converts x to absolute to avoid the error. + +#... +0+2000 A x +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/pr14962.t b/binutils-2.24/ld/testsuite/ld-scripts/pr14962.t new file mode 100644 index 0000000..f399acd --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/pr14962.t @@ -0,0 +1,8 @@ +NOCROSSREFS ( .text .data ) +x = ABSOLUTE(x); +SECTIONS +{ + .text : { *(.text) } + .data : { *(.data) } + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/pr14962a.s b/binutils-2.24/ld/testsuite/ld-scripts/pr14962a.s new file mode 100644 index 0000000..abaaaa6 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/pr14962a.s @@ -0,0 +1,10 @@ + .globl main + .globl start + .globl _start + .globl __start + .text +main: +start: +_start: +__start: + .dc.a x diff --git a/binutils-2.24/ld/testsuite/ld-scripts/pr14962b.s b/binutils-2.24/ld/testsuite/ld-scripts/pr14962b.s new file mode 100644 index 0000000..db27d76 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/pr14962b.s @@ -0,0 +1,4 @@ + .data + .globl x +x: + .dc.a x diff --git a/binutils-2.24/ld/testsuite/ld-scripts/provide-1.d b/binutils-2.24/ld/testsuite/ld-scripts/provide-1.d new file mode 100644 index 0000000..ac8719a --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/provide-1.d @@ -0,0 +1,9 @@ +#source: provide-1.s +#ld: -T provide-1.t +#objdump: -s -j .data + +.*: file format .* + +Contents of section .data: + [0-9a-f]* (1020)?0000(2010)? (2020)?0000(2020)? 00000000 .* +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/provide-1.s b/binutils-2.24/ld/testsuite/ld-scripts/provide-1.s new file mode 100644 index 0000000..1e33540 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/provide-1.s @@ -0,0 +1,4 @@ + .data + .globl foo +foo: .long 0 + .p2align 4 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/provide-1.t b/binutils-2.24/ld/testsuite/ld-scripts/provide-1.t new file mode 100644 index 0000000..6b96b33 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/provide-1.t @@ -0,0 +1,12 @@ +SECTIONS +{ + .data 0x2000 : + { + LONG (foo) + LONG (bar) + . = ALIGN (0x10); + *(.data) + } + PROVIDE (foo = .); + PROVIDE (bar = .); +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/provide-2.d b/binutils-2.24/ld/testsuite/ld-scripts/provide-2.d new file mode 100644 index 0000000..e151b30 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/provide-2.d @@ -0,0 +1,7 @@ +#source: provide-2.s +#ld: -T provide-2.t +#nm: -B +#... +0+3 A baz +0+2000 D foo +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/provide-2.s b/binutils-2.24/ld/testsuite/ld-scripts/provide-2.s new file mode 100644 index 0000000..f9138db --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/provide-2.s @@ -0,0 +1,8 @@ + .data + .globl foo +foo: .long 0 + + .globl baz + .long baz + + .p2align 4 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/provide-2.t b/binutils-2.24/ld/testsuite/ld-scripts/provide-2.t new file mode 100644 index 0000000..fe30dd8 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/provide-2.t @@ -0,0 +1,10 @@ +SECTIONS +{ + PROVIDE (foo = 1); + PROVIDE (bar = 2); + PROVIDE (baz = 3); + .data 0x2000 : + { + *(.data) + } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/provide-3.d b/binutils-2.24/ld/testsuite/ld-scripts/provide-3.d new file mode 100644 index 0000000..c8b12da --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/provide-3.d @@ -0,0 +1,3 @@ +#source: provide-3.s +#ld: -T provide-3.t +#error: symbol defined in linker script and object file diff --git a/binutils-2.24/ld/testsuite/ld-scripts/provide-3.s b/binutils-2.24/ld/testsuite/ld-scripts/provide-3.s new file mode 100644 index 0000000..1e33540 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/provide-3.s @@ -0,0 +1,4 @@ + .data + .globl foo +foo: .long 0 + .p2align 4 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/provide-3.t b/binutils-2.24/ld/testsuite/ld-scripts/provide-3.t new file mode 100644 index 0000000..f6229d4 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/provide-3.t @@ -0,0 +1,11 @@ +SECTIONS +{ + .data : + { + LONG (foo) + LONG (bar) + *(.data) + } + foo = .; + bar = .; +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/provide.exp b/binutils-2.24/ld/testsuite/ld-scripts/provide.exp new file mode 100644 index 0000000..6db399f --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/provide.exp @@ -0,0 +1,45 @@ +# Test PROVIDE in a linker script. +# By Nathan Sidwell, CodeSourcery LLC +# Copyright 2004, 2005, 2006, 2007 +# 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. + +# AIX maps .text and .data to other sections. +# a.out objdump displays the file header inside the text segment, +# confusing run_dump_test. + +if {[istarget "rs6000-*-aix*"] || [is_aout_format]} { + unsupported provide-1 + unsupported provide-2 + unsupported provide-3 + return +} + +global LDFLAGS +set saved_LDFLAGS "$LDFLAGS" +if [istarget "x86_64-*-mingw*"] then { + set LDFLAGS "$LDFLAGS --image-base 0" +} + +run_dump_test provide-1 +run_dump_test provide-2 +setup_xfail *-*-* +run_dump_test provide-3 + +set LDFLAGS "$saved_LDFLAGS" diff --git a/binutils-2.24/ld/testsuite/ld-scripts/region-alias-1.d b/binutils-2.24/ld/testsuite/ld-scripts/region-alias-1.d new file mode 100644 index 0000000..35a3931 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/region-alias-1.d @@ -0,0 +1,3 @@ +#source: script.s +#ld: -T region-alias-1.t +#error: .*:[0-9]+: error: redefinition of memory region alias `MY_ALIAS' diff --git a/binutils-2.24/ld/testsuite/ld-scripts/region-alias-1.t b/binutils-2.24/ld/testsuite/ld-scripts/region-alias-1.t new file mode 100644 index 0000000..91f8100 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/region-alias-1.t @@ -0,0 +1,7 @@ +MEMORY +{ + MY_REGION (ARX) : ORIGIN = 0, LENGTH = 32K +} + +REGION_ALIAS ("MY_ALIAS", MY_REGION); +REGION_ALIAS ("MY_ALIAS", MY_REGION); diff --git a/binutils-2.24/ld/testsuite/ld-scripts/region-alias-2.d b/binutils-2.24/ld/testsuite/ld-scripts/region-alias-2.d new file mode 100644 index 0000000..c18ccb3 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/region-alias-2.d @@ -0,0 +1,3 @@ +#source: script.s +#ld: -T region-alias-2.t +#error: .*:[0-9]+: error: memory region `NIL' for alias `MY_ALIAS' does not exist diff --git a/binutils-2.24/ld/testsuite/ld-scripts/region-alias-2.t b/binutils-2.24/ld/testsuite/ld-scripts/region-alias-2.t new file mode 100644 index 0000000..a6b1514 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/region-alias-2.t @@ -0,0 +1,6 @@ +MEMORY +{ + MY_REGION (ARX) : ORIGIN = 0, LENGTH = 32K +} + +REGION_ALIAS ("MY_ALIAS", "NIL"); diff --git a/binutils-2.24/ld/testsuite/ld-scripts/region-alias-3.d b/binutils-2.24/ld/testsuite/ld-scripts/region-alias-3.d new file mode 100644 index 0000000..cc953b7 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/region-alias-3.d @@ -0,0 +1,3 @@ +#source: script.s +#ld: -T region-alias-3.t +#error: .*:[0-9]+: error: alias for default memory region diff --git a/binutils-2.24/ld/testsuite/ld-scripts/region-alias-3.t b/binutils-2.24/ld/testsuite/ld-scripts/region-alias-3.t new file mode 100644 index 0000000..667879b --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/region-alias-3.t @@ -0,0 +1,6 @@ +MEMORY +{ + MY_REGION (ARX) : ORIGIN = 0, LENGTH = 32K +} + +REGION_ALIAS ("MY_ALIAS", "*default*"); diff --git a/binutils-2.24/ld/testsuite/ld-scripts/region-alias-4.d b/binutils-2.24/ld/testsuite/ld-scripts/region-alias-4.d new file mode 100644 index 0000000..b02d45c --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/region-alias-4.d @@ -0,0 +1,3 @@ +#source: script.s +#ld: -T region-alias-4.t +#error: .*:[0-9]+: error: alias for default memory region diff --git a/binutils-2.24/ld/testsuite/ld-scripts/region-alias-4.t b/binutils-2.24/ld/testsuite/ld-scripts/region-alias-4.t new file mode 100644 index 0000000..da9dff5 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/region-alias-4.t @@ -0,0 +1,6 @@ +MEMORY +{ + MY_REGION (ARX) : ORIGIN = 0, LENGTH = 32K +} + +REGION_ALIAS ("*default*", MY_REGION); diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-at.exp b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at.exp new file mode 100644 index 0000000..9095273 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at.exp @@ -0,0 +1,33 @@ +# Test for proper diagnosis of overflowed memory regions. +# 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. + +if ![is_elf_format] { + return +} + +load_lib ld-lib.exp + +set test_list [lsort [glob -nocomplain $srcdir/$subdir/rgn-at*.d]] +foreach test_file $test_list { + set test_name [file rootname $test_file] + set map_file "tmpdir/[file tail $test_name].map" + verbose $test_name + run_dump_test $test_name +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-at.s b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at.s new file mode 100644 index 0000000..0628046 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at.s @@ -0,0 +1,6 @@ + .section .text + .long 0x12345678 + .section .data + .long 0x9abcdef0 + .section .bss + .long 0 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-at1.d b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at1.d new file mode 100644 index 0000000..f301bbb --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at1.d @@ -0,0 +1,15 @@ +# name: rgn-at1 +# source: rgn-at.s +# ld: -T rgn-at1.t +# objdump: -w -h +# xfail: rx-*-* +# FAILS on the RX because the linker has to set LMA == VMA for the +# Renesas loader. + +.*: file format .* + +Sections: +Idx +Name +Size +VMA +LMA +File off +Algn +Flags + 0 .text +0+[0-9a-f][0-9a-f] +0+0010000 +0+0020000 +.* + 1 .data +0+[0-9a-f][0-9a-f] +0+00100[0-9a-f]+ +0+00200[0-9a-f]+ +.* + 2 .bss +0+[0-9a-f][0-9a-f] +0+00100[0-9a-f]+ +0+00200[0-9a-f]+ +.* diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-at1.t b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at1.t new file mode 100644 index 0000000..610be2a --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at1.t @@ -0,0 +1,13 @@ +/* Memory region at test, >AT should propagate by default */ + +MEMORY { + ram : ORIGIN = 0x10000, LENGTH = 0x100 + rom : ORIGIN = 0x20000, LENGTH = 0x200 +} +_start = 0x1000; +SECTIONS { + .text : { *(.text) } >ram AT>rom + .data : { *(.data) } >ram /* default AT>rom */ + .bss : { *(.bss) } >ram + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-at2.d b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at2.d new file mode 100644 index 0000000..8fd5f1a --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at2.d @@ -0,0 +1,15 @@ +# name: rgn-at2 +# source: rgn-at.s +# ld: -T rgn-at2.t +# objdump: -w -h +# xfail: rx-*-* +# FAILS on the RX because the linker has to set LMA == VMA for the +# Renesas loader. + +.*: file format .* + +Sections: +Idx +Name +Size +VMA +LMA +File off +Algn +Flags + 0 .text +0+[0-9a-f][0-9a-f] +0+0010000 +0+0020000 +.* + 1 .data +0+[0-9a-f][0-9a-f] +0+0030000 +0+0030000 +.* + 2 .bss +0+[0-9a-f][0-9a-f] +0+00300[0-9a-f]+ +0+00300[0-9a-f]+ +.* diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-at2.t b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at2.t new file mode 100644 index 0000000..57fd88c --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at2.t @@ -0,0 +1,14 @@ +/* Memory region at test, >AT should propagate by default */ + +MEMORY { + ram : ORIGIN = 0x10000, LENGTH = 0x100 + rom : ORIGIN = 0x20000, LENGTH = 0x200 + other : ORIGIN = 0x30000, LENGTH = 0x200 +} +_start = 0x1000; +SECTIONS { + .text : { *(.text) } >ram AT>rom + .data : { *(.data) } >other /* No default AT>rom */ + .bss : { *(.bss) } >other + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-at3.d b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at3.d new file mode 100644 index 0000000..b0ea08a --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at3.d @@ -0,0 +1,19 @@ +# name: rgn-at3 +# source: rgn-at.s +# ld: -T rgn-at3.t +# objdump: -w -h +# xfail: rx-*-* *-*-nacl* +# FAILS on the RX because the linker has to set LMA == VMA for the +# Renesas loader. +# FAILs on NaCl targets because the linker extends the first segment +# to fill out the page, making its p_vaddr+p_memsz cover the sh_addr +# of .bss too, which makes BFD compute its LMA from the p_paddr of the +# text segment. + +.*: file format .* + +Sections: +Idx +Name +Size +VMA +LMA +File off +Algn +Flags + 0 .text +0+[0-9a-f][0-9a-f] +0+0010000 +0+0020000 +.* + 1 .data +0+[0-9a-f][0-9a-f] +0+00100[0-9a-f]+ +0+0030000 +.* + 2 .bss +0+[0-9a-f][0-9a-f] +0+00100[0-9a-f]+ +0+00300[0-9a-f]+ +.* diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-at3.t b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at3.t new file mode 100644 index 0000000..4622e7e --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at3.t @@ -0,0 +1,13 @@ +/* Memory region at test, >AT should propagate by default */ + +MEMORY { + ram : ORIGIN = 0x10000, LENGTH = 0x100 + rom : ORIGIN = 0x20000, LENGTH = 0x200 +} +_start = 0x1000; +SECTIONS { + .text : { *(.text) } >ram AT>rom + .data : AT (0x30000) { *(.data) } >ram /* NO default AT>rom */ + .bss : { *(.bss) } >ram /* NO default AT>rom */ + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-at4.d b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at4.d new file mode 100644 index 0000000..9837343 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at4.d @@ -0,0 +1,16 @@ +# name: rgn-at4 +# source: rgn-at.s +# ld: -T rgn-at4.t +# objdump: -w -h +# xfail: rx-*-* +# FAILS on the RX because the linker has to set LMA == VMA for the +# Renesas loader. + +.*: file format .* + +Sections: +Idx +Name +Size +VMA +LMA +File off +Algn +Flags + 0 .text +0+[0-9a-f][0-9a-f] +0+0010000 +0+0020000 +.* + 1 .data +0+[0-9a-f][0-9a-f] +0+00100[0-9a-f]+ +0+00200[0-9a-f]+ +.* + 2 .bss +0+[0-9a-f][0-9a-f] +0+00100[0-9a-f]+ +0+00200[0-9a-f]+ +.* + 3 .trail +0+[0-9a-f][0-9a-f] +0+00100[0-9a-f]+ +0+00200[0-9a-f]+ +.* diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-at4.t b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at4.t new file mode 100644 index 0000000..0e3fec4 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at4.t @@ -0,0 +1,14 @@ +/* Memory region at test, >AT should propagate by default */ + +MEMORY { + ram : ORIGIN = 0x10000, LENGTH = 0x100 + rom : ORIGIN = 0x20000, LENGTH = 0x200 +} +_start = 0x1000; +SECTIONS { + .text : { *(.text) } >ram AT>rom + .data : { *(.data) } >ram + .bss : { *(.bss) } >ram + .trail : { LONG(5) } >ram + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-at5.d b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at5.d new file mode 100644 index 0000000..7ba9caf --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at5.d @@ -0,0 +1,20 @@ +# name: rgn-at5 +# source: rgn-at5.s +# ld: -T rgn-at5.t -z max-page-size=0x1000 +# objdump: -w -h +# target: *-*-linux* *-*-gnu* +# xfail: rx-*-* +# FAILS on the RX because the linker has to set LMA == VMA for the +# Renesas loader. + +.*: file format .* + +Sections: +Idx +Name +Size +VMA +LMA +File off +Algn +Flags + 0 .sec0 +0+4 +0+2000 +0+2000 +0+1000 +.* + 1 .sec1 +0+4 +0+1000 +0+2004 +0+2000 +.* + 2 .sec2 +0+4 +0+4000 +0+603c +0+4000 +.* + 3 .sec3 +0+4 +0+5000 +0+5000 +0+3000 +.* + 4 .sec4 +0+4 +0+2008 +0+2008 +0+2008 +.* + 5 .sec5 +0+4 +0+200c +0+200c +0+200c +.* +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-at5.s b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at5.s new file mode 100644 index 0000000..ce8576c --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at5.s @@ -0,0 +1,14 @@ + .section .sec0, "a" + .long 0 + + .section .sec1, "a" + .long 0x11 + + .section .sec2, "a" + .long 0x22 + + .section .sec3, "a" + .long 0x33 + + .section .sec4, "a" + .long 0x44 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-at5.t b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at5.t new file mode 100644 index 0000000..3a35994 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at5.t @@ -0,0 +1,26 @@ +MEMORY +{ + region1 : ORIGIN = 0x1000, LENGTH = 0x1000 , + region2 (r) : org = 0x2000, len = 300 + region3 (wx) : o = 0x4000, l = 4 + region4 (!r) : o = 0x6000 + 60, len = 0x30 * 0x6 +} + +SECTIONS +{ + .sec0 : { *(*.sec0) } + + .sec1 ORIGIN (region1) : { *(*.sec1) } AT> region2 + + fred = ORIGIN (region1) + LENGTH (region1); + + .sec2 : { *(*.sec2) } > region3 AT> region4 + + .sec3 0x5000 : { *(*.sec3) } + + .sec4 : { *(*.sec4) } AT> region2 + + .sec5 : { LONG(0x5555) } > region2 + + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-at6.d b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at6.d new file mode 100644 index 0000000..80f9b8a --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at6.d @@ -0,0 +1,9 @@ +#source: rgn-at6.s +#ld: -T rgn-at6.t +#objdump: -h --wide +#xfail: rx-*-* +# Test that lma is aligned as for vma when lma_region==region. + +#... +.* 0+10000 +0+10000 .* +.* 0+10100 +0+10100 .* diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-at6.s b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at6.s new file mode 100644 index 0000000..20571bc --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at6.s @@ -0,0 +1,6 @@ + .text + .long 0 + + .data + .p2align 8 + .long 0 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-at6.t b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at6.t new file mode 100644 index 0000000..0408dcd --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at6.t @@ -0,0 +1,11 @@ +MEMORY +{ + ram : ORIGIN = 0x10000, LENGTH = 0x10000 +} + +SECTIONS +{ + .text : {*(.text)} > ram AT> ram + .data : ALIGN (16) {*(.data)} > ram AT> ram + /DISCARD/ : {*(*)} +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-at7.d b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at7.d new file mode 100644 index 0000000..a12ca17 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at7.d @@ -0,0 +1,9 @@ +#source: rgn-at6.s +#ld: -T rgn-at7.t +#objdump: -h --wide +#xfail: rx-*-* +# Test that lma is only aligned by script when lma_region!=region. + +#... +.* 0+10000 +0+20000 .* +.* 0+10100 +0+20010 .* diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-at7.t b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at7.t new file mode 100644 index 0000000..c1f2789 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at7.t @@ -0,0 +1,12 @@ +MEMORY +{ + ram : ORIGIN = 0x10000, LENGTH = 0x10000 + rom : ORIGIN = 0x20000, LENGTH = 0x10000 +} + +SECTIONS +{ + .text : {*(.text)} > ram AT> rom + .data : ALIGN (16) {*(.data)} > ram AT> rom + /DISCARD/ : {*(*)} +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-at8.d b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at8.d new file mode 100644 index 0000000..c9d6350 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at8.d @@ -0,0 +1,9 @@ +#source: rgn-at6.s +#ld: -T rgn-at8.t +#objdump: -h --wide +#xfail: rx-*-* +# Test that lma is aligned when lma_region!=region and requested by script. + +#... +.* 0+10000 +0+20000 .* +.* 0+10100 +0+20100 .* diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-at8.t b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at8.t new file mode 100644 index 0000000..e8aa1c7 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-at8.t @@ -0,0 +1,12 @@ +MEMORY +{ + ram : ORIGIN = 0x10000, LENGTH = 0x10000 + rom : ORIGIN = 0x20000, LENGTH = 0x10000 +} + +SECTIONS +{ + .text : ALIGN_WITH_INPUT {*(.text)} > ram AT> rom + .data : ALIGN_WITH_INPUT {*(.data)} > ram AT> rom + /DISCARD/ : {*(*)} +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-over.exp b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over.exp new file mode 100644 index 0000000..8192487 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over.exp @@ -0,0 +1,54 @@ +# Test for proper diagnosis of overflowed memory regions. +# Copyright 2007, 2008 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. + +if ![is_elf_format] { + return +} + +load_lib ld-lib.exp + +set old_ldflags $LDFLAGS +if { [istarget spu*-*-*] } { + set LDFLAGS "$LDFLAGS --no-overlays" +} + +set test_list [lsort [glob -nocomplain $srcdir/$subdir/rgn-over*.d]] +foreach test_file $test_list { + set test_name [file rootname $test_file] + set map_file "tmpdir/[file tail $test_name].map" + verbose $test_name + run_dump_test $test_name + + if { ! [regexp ".*-ok.d" $test_file] } { + set testname "[file tail $test_name] (map check)" + if [file exists $map_file] { + # compare the map file to the expectations in the .d file + # (run_dump_test can't do that). + if [regexp_diff $map_file $test_file] { + fail $testname + } else { + pass $testname + } + } else { + untested $testname + } + } +} +set LDFLAGS $old_ldflags diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-over.s b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over.s new file mode 100644 index 0000000..f651cce --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over.s @@ -0,0 +1,9 @@ + .section .txt, "ax", "progbits" + .4byte 0x11223344 + .4byte 0x55667788 + .4byte 0x99aabbcc + + .section .dat, "aw", "progbits" + .4byte 0x01020304 + .4byte 0x05060708 + .4byte 0x090a0b0c diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-over1.d b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over1.d new file mode 100644 index 0000000..54892be --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over1.d @@ -0,0 +1,35 @@ +# name: rgn-over1 +# source: rgn-over.s +# ld: -T rgn-over1.t -Map tmpdir/rgn-over1.map +# error: \A[^ \n]*?ld[^:\n]*?: [^\n]*?section \`.text' will not fit in region `r1'\n[^ \n]*?ld[^:\n]*?: region `r1' overflowed by 16 bytes\Z + +Discarded input sections +#... +Memory\s+Configuration + +Name\s+Origin\s+Length\s+Attributes +bss\s+0x0+0000\s+0x0+0000\s+xrw +r1\s+0x0+1000\s+0x0+0008\s+xrw +\*default\*\s+0x0+0000\s+0xf+ffff + +Linker\s+script\s+and\s+memory\s+map + +\s*0x0+1000\s+_start\s+=\s+0x1000 + +\s*\.bss\s+0x0+0000\s+0x0 +\s*\*\(\.bss\) +\s*\.bss\s+0x0+0000\s+0x0\s+.*? + +\s*\.text\s+0x0+1000\s+0xc +\s*\*\(\.txt\) +\s*\.txt\s+0x0+1000\s+0xc\s+.*? + +\s*\.data\s+0x0+100c\s+0xc +\s*\*\(\.dat\) +\s*\.dat\s+0x0+100c\s+0xc\s+.*? + +/DISCARD/ + \*\(\*\) +LOAD\s+.*? +OUTPUT\(.*?\) +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-over1.t b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over1.t new file mode 100644 index 0000000..9c14f70 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over1.t @@ -0,0 +1,13 @@ +/* Memory region overflow tests: one region, first output sect doesn't fit. */ + +MEMORY { + bss (rwx) : ORIGIN = 0, LENGTH = 0 + r1 (rwx) : ORIGIN = 0x1000, LENGTH = 8 +} +_start = 0x1000; +SECTIONS { + .bss : { *(.bss) } > bss + .text : { *(.txt) } > r1 + .data : { *(.dat) } > r1 + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-over2.d b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over2.d new file mode 100644 index 0000000..1a5afea --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over2.d @@ -0,0 +1,35 @@ +# name: rgn-over2 +# source: rgn-over.s +# ld: -T rgn-over2.t -Map tmpdir/rgn-over2.map +# error: \A[^ \n]*?ld[^:\n]*?: [^\n]*?section `\.data' will not fit in region `r1'\n[^ \n]*?ld[^:\n]*?: region `r1' overflowed by 4 bytes\Z + +Discarded input sections +#... +Memory\s+Configuration + +Name\s+Origin\s+Length\s+Attributes +bss\s+0x0+0000\s+0x0+0000\s+xrw +r1\s+0x0+1000\s+0x0+0014\s+xrw +\*default\*\s+0x0+0000\s+0xf+ffff + +Linker\s+script\s+and\s+memory\s+map + +\s*0x0+1000\s+_start\s+=\s+0x1000 + +\s*\.bss\s+0x0+0000\s+0x0 +\s*\*\(\.bss\) +\s*\.bss\s+0x0+0000\s+0x0\s+.*? + +\s*\.text\s+0x0+1000\s+0xc +\s*\*\(\.txt\) +\s*\.txt\s+0x0+1000\s+0xc\s+.*? + +\s*\.data\s+0x0+100c\s+0xc +\s*\*\(\.dat\) +\s*\.dat\s+0x0+100c\s+0xc\s+.*? + +/DISCARD/ + \*\(\*\) +LOAD\s+.*? +OUTPUT\(.*?\) +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-over2.t b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over2.t new file mode 100644 index 0000000..b38a9c1 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over2.t @@ -0,0 +1,14 @@ +/* Memory region overflow tests: one region, first output sect fits, + second doesn't. */ + +MEMORY { + bss (rwx) : ORIGIN = 0, LENGTH = 0 + r1 (rwx) : ORIGIN = 0x1000, LENGTH = 20 +} +_start = 0x1000; +SECTIONS { + .bss : { *(.bss) } > bss + .text : { *(.txt) } > r1 + .data : { *(.dat) } > r1 + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-over3.d b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over3.d new file mode 100644 index 0000000..76fa7c5 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over3.d @@ -0,0 +1,36 @@ +# name: rgn-over3 +# source: rgn-over.s +# ld: -T rgn-over3.t -Map tmpdir/rgn-over3.map +# error: \A[^ \n]*?ld[^:\n]*?: [^\n]*?section `\.text' will not fit in region `r1'\n[^ \n]*?ld[^:\n]*?: [^\n]*?section `\.data' will not fit in region `r2'\n[^ \n]*?ld[^:\n]*?: region `r1' overflowed by 4 bytes\n[^ \n]*?ld[^:\n]*?: region `r2' overflowed by 4 bytes\Z + +Discarded input sections +#... +Memory\s+Configuration + +Name\s+Origin\s+Length\s+Attributes +bss\s+0x0+0000\s+0x0+0000\s+xrw +r1\s+0x0+1000\s+0x0+0008\s+xrw +r2\s+0x0+2000\s+0x0+0008\s+xrw +\*default\*\s+0x0+0000\s+0xf+ffff + +Linker\s+script\s+and\s+memory\s+map + +\s*0x0+1000\s+_start\s+=\s+0x1000 + +\s*\.bss\s+0x0+0000\s+0x0 +\s*\*\(\.bss\) +\s*\.bss\s+0x0+0000\s+0x0\s+.*? + +\s*\.text\s+0x0+1000\s+0xc +\s*\*\(\.txt\) +\s*\.txt\s+0x0+1000\s+0xc\s+.*? + +\s*\.data\s+0x0+2000\s+0xc +\s*\*\(\.dat\) +\s*\.dat\s+0x0+2000\s+0xc\s+.*? + +/DISCARD/ + \*\(\*\) +LOAD\s+.*? +OUTPUT\(.*?\) +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-over3.t b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over3.t new file mode 100644 index 0000000..5341fb5 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over3.t @@ -0,0 +1,15 @@ +/* Memory region overflow tests: two regions, each too small for the single + section placed there. */ + +MEMORY { + bss (rwx) : ORIGIN = 0, LENGTH = 0 + r1 (rwx) : ORIGIN = 0x1000, LENGTH = 8 + r2 (rwx) : ORIGIN = 0x2000, LENGTH = 8 +} +_start = 0x1000; +SECTIONS { + .bss : { *(.bss) } > bss + .text : { *(.txt) } > r1 + .data : { *(.dat) } > r2 + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-over4.d b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over4.d new file mode 100644 index 0000000..1087aec --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over4.d @@ -0,0 +1,36 @@ +# name: rgn-over4 +# source: rgn-over.s +# ld: -T rgn-over4.t -Map tmpdir/rgn-over4.map +# error: \A[^ \n]*?ld[^:\n]*?: [^:\n]*?section `\.text' will not fit in region `r1'\n[^ \n]*?ld[^:\n]*?: region `r1' overflowed by 16 bytes\Z + +Discarded input sections +#... +Memory\s+Configuration + +Name\s+Origin\s+Length\s+Attributes +bss\s+0x0+0000\s+0x0+0000\s+xrw +r1\s+0x0+1000\s+0x0+0008\s+xrw +v1\s+0x0+2000\s+0x0+0018\s+xrw +\*default\*\s+0x0+0000\s+0xf+ffff + +Linker\s+script\s+and\s+memory\s+map + +\s*0x0+1000\s+_start\s+=\s+0x1000 + +\s*\.bss\s+0x0+0000\s+0x0 +\s*\*\(\.bss\) +\s*\.bss\s+0x0+0000\s+0x0\s+.*? + +\s*\.text\s+0x0+1000\s+0xc\s+load\s+address\s+0x0+2000 +\s*\*\(\.txt\) +\s*\.txt\s+0x0+1000\s+0xc\s+.*? + +\s*\.data\s+0x0+100c\s+0xc\s+load\s+address\s+0x0+200c +\s*\*\(\.dat\) +\s*\.dat\s+0x0+100c\s+0xc\s+.*? + +/DISCARD/ + \*\(\*\) +LOAD\s+.*? +OUTPUT\(.*?\) +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-over4.t b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over4.t new file mode 100644 index 0000000..d2463e9 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over4.t @@ -0,0 +1,14 @@ +/* Memory region overflow tests: overflow VMA but not LMA. */ + +MEMORY { + bss (rwx) : ORIGIN = 0, LENGTH = 0 + r1 (rwx) : ORIGIN = 0x1000, LENGTH = 8 + v1 (rwx) : ORIGIN = 0x2000, LENGTH = 24 +} +_start = 0x1000; +SECTIONS { + .bss : { *(.bss) } > bss + .text : { *(.txt) } > r1 AT> v1 + .data : { *(.dat) } > r1 AT> v1 + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-over5.d b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over5.d new file mode 100644 index 0000000..734d9fe --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over5.d @@ -0,0 +1,36 @@ +# name: rgn-over5 +# source: rgn-over.s +# ld: -T rgn-over5.t -Map tmpdir/rgn-over5.map +# error: \A[^ \n]*?ld[^:\n]*?: [^\n]*?section `\.text' will not fit in region `v1'\n[^ \n]*?ld[^:\n]*?: region `v1' overflowed by 16 bytes\Z + +Discarded input sections +#... +Memory\s+Configuration + +Name\s+Origin\s+Length\s+Attributes +bss\s+0x0+0000\s+0x0+0000\s+xrw +r1\s+0x0+1000\s+0x0+0018\s+xrw +v1\s+0x0+2000\s+0x0+0008\s+xrw +\*default\*\s+0x0+0000\s+0xf+ffff + +Linker\s+script\s+and\s+memory\s+map + +\s*0x0+1000\s+_start\s+=\s+0x1000 + +\s*\.bss\s+0x0+0000\s+0x0 +\s*\*\(\.bss\) +\s*\.bss\s+0x0+0000\s+0x0\s+.*? + +\s*\.text\s+0x0+1000\s+0xc\s+load\s+address\s+0x0+2000 +\s*\*\(\.txt\) +\s*\.txt\s+0x0+1000\s+0xc\s+.*? + +\s*\.data\s+0x0+100c\s+0xc\s+load\s+address\s+0x0+200c +\s*\*\(\.dat\) +\s*\.dat\s+0x0+100c\s+0xc\s+.*? + +/DISCARD/ + \*\(\*\) +LOAD\s+.*? +OUTPUT\(.*?\) +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-over5.t b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over5.t new file mode 100644 index 0000000..2b0ae68 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over5.t @@ -0,0 +1,14 @@ +/* Memory region overflow tests: overflow LMA but not VMA. */ + +MEMORY { + bss (rwx) : ORIGIN = 0, LENGTH = 0 + r1 (rwx) : ORIGIN = 0x1000, LENGTH = 24 + v1 (rwx) : ORIGIN = 0x2000, LENGTH = 8 +} +_start = 0x1000; +SECTIONS { + .bss : { *(.bss) } > bss + .text : { *(.txt) } > r1 AT> v1 + .data : { *(.dat) } > r1 AT> v1 + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-over6.d b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over6.d new file mode 100644 index 0000000..00b41d0 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over6.d @@ -0,0 +1,36 @@ +# name: rgn-over6 +# source: rgn-over.s +# ld: -T rgn-over6.t -Map tmpdir/rgn-over6.map +# error: \A[^ \n]*?ld[^:\n]*?: [^\n]*?section `\.text' will not fit in region `r1'\n[^ \n]*?ld[^:\n]*?: [^\n]*?section `\.text' will not fit in region `v1'\n[^ \n]*?ld[^:\n]*?: region `r1' overflowed by 16 bytes\n[^ \n]*?ld[^:\n]*?: region `v1' overflowed by 16 bytes\Z + +Discarded input sections +#... +Memory\s+Configuration + +Name\s+Origin\s+Length\s+Attributes +bss\s+0x0+0000\s+0x0+0000\s+xrw +r1\s+0x0+1000\s+0x0+0008\s+xrw +v1\s+0x0+2000\s+0x0+0008\s+xrw +\*default\*\s+0x0+0000\s+0xf+ffff + +Linker\s+script\s+and\s+memory\s+map + +\s*0x0+1000\s+_start\s+=\s+0x1000 + +\s*\.bss\s+0x0+0000\s+0x0 +\s*\*\(\.bss\) +\s*\.bss\s+0x0+0000\s+0x0\s+.*? + +\s*\.text\s+0x0+1000\s+0xc\s+load\s+address\s+0x0+2000 +\s*\*\(\.txt\) +\s*\.txt\s+0x0+1000\s+0xc\s+.*? + +\s*\.data\s+0x0+100c\s+0xc\s+load\s+address\s+0x0+200c +\s*\*\(\.dat\) +\s*\.dat\s+0x0+100c\s+0xc\s+.*? + +/DISCARD/ + \*\(\*\) +LOAD\s+.*? +OUTPUT\(.*?\) +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-over6.t b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over6.t new file mode 100644 index 0000000..b78d184 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over6.t @@ -0,0 +1,14 @@ +/* Memory region overflow tests: overflow LMA and VMA. */ + +MEMORY { + bss (rwx) : ORIGIN = 0, LENGTH = 0 + r1 (rwx) : ORIGIN = 0x1000, LENGTH = 8 + v1 (rwx) : ORIGIN = 0x2000, LENGTH = 8 +} +_start = 0x1000; +SECTIONS { + .bss : { *(.bss) } > bss + .text : { *(.txt) } > r1 AT> v1 + .data : { *(.dat) } > r1 AT> v1 + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-over7.d b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over7.d new file mode 100644 index 0000000..50bd6af --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over7.d @@ -0,0 +1,36 @@ +# name: rgn-over7 +# source: rgn-over.s +# ld: -T rgn-over7.t -Map tmpdir/rgn-over7.map +# error: \A[^ \n]*?ld[^:\n]*?: [^\n]*?section `\.text' will not fit in region `r1'\n[^ \n]*?ld[^:\n]*?: section \.data loaded at \[0+1008,0+1013\] overlaps section \.text loaded at \[0+1000,0+100b\]\n[^ \n]*?ld[^:\n]*?: region `r1' overflowed by 4 bytes\Z + +Discarded input sections +#... +Memory\s+Configuration + +Name\s+Origin\s+Length\s+Attributes +bss\s+0x0+0000\s+0x0+0000\s+xrw +r1\s+0x0+1000\s+0x0+0008\s+xrw +r2\s+0x0+1008\s+0x0+000c\s+xrw +\*default\*\s+0x0+0000\s+0xf+ffff + +Linker\s+script\s+and\s+memory\s+map + +\s*0x0+1000\s+_start\s+=\s+0x1000 + +\s*\.bss\s+0x0+0000\s+0x0 +\s*\*\(\.bss\) +\s*\.bss\s+0x0+0000\s+0x0\s+.*? + +\s*\.text\s+0x0+1000\s+0xc +\s*\*\(\.txt\) +\s*\.txt\s+0x0+1000\s+0xc\s+.*? + +\s*\.data\s+0x0+1008\s+0xc +\s*\*\(\.dat\) +\s*\.dat\s+0x0+1008\s+0xc\s+.*? + +/DISCARD/ + \*\(\*\) +LOAD\s+.*? +OUTPUT\(.*?\) +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-over7.t b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over7.t new file mode 100644 index 0000000..4288e84 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over7.t @@ -0,0 +1,14 @@ +/* Memory region overflow tests: overflow r1 plus text/data collision. */ + +MEMORY { + bss (rwx) : ORIGIN = 0, LENGTH = 0 + r1 (rwx) : ORIGIN = 0x1000, LENGTH = 8 + r2 (rwx) : ORIGIN = 0x1008, LENGTH = 12 +} +_start = 0x1000; +SECTIONS { + .bss : { *(.bss) } > bss + .text : { *(.txt) } > r1 + .data : { *(.dat) } > r2 + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-over8-ok.d b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over8-ok.d new file mode 100644 index 0000000..fe6b1c9 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over8-ok.d @@ -0,0 +1,19 @@ +# name: rgn-over8 +# source: rgn-over8.s +# ld: -T rgn-over8.t +# objdump: -w -h +# xfail: rx-*-* *-*-nacl* +# FAILS on the RX because the linker has to set LMA == VMA for the +# Renesas loader. +# FAILs on NaCl targets because the linker extends the first segment +# to fill out the page, making its p_vaddr+p_memsz cover the sh_addr +# of .bss too, which makes BFD compute its LMA from the p_paddr of the +# text segment. + +.*: file format .* + +Sections: +Idx +Name +Size +VMA +LMA +File off +Algn +Flags + 0 .text 0+0000400 0+0000000 0+0000000 [0-9a-f]+ 2\*\*[0-9]+ CONTENTS, ALLOC, LOAD, READONLY, CODE + 1 .data 0+0000400 0+0001000 0+0000400 [0-9a-f]+ 2\*\*[0-9]+ CONTENTS, ALLOC, LOAD, DATA + 2 .bss 0+0000400 0+0001400 0+0000800 [0-9a-f]+ 2\*\*[0-9]+ ALLOC diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-over8.s b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over8.s new file mode 100644 index 0000000..0077a4f --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over8.s @@ -0,0 +1,7 @@ + .text + .globl main + .zero 1024 + .data + .zero 1024 + .section .bss, "aw", "nobits" + .zero 1024 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/rgn-over8.t b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over8.t new file mode 100644 index 0000000..7623b19 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/rgn-over8.t @@ -0,0 +1,13 @@ +/* Memory region overflow tests: bss to LMA doesn't cause overflow. */ + +MEMORY { + rom (rwx) : ORIGIN = 0, LENGTH = 2048 + ram (rwx) : ORIGIN = 0x1000, LENGTH = 2048 +} +_start = 0x0; +SECTIONS { + .text : { *(.text) } >rom AT>rom + .data : { *(.data) } >ram AT>rom + .bss : { *(.bss) } >ram AT>rom + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sane1.d b/binutils-2.24/ld/testsuite/ld-scripts/sane1.d new file mode 100644 index 0000000..d11a210 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sane1.d @@ -0,0 +1,58 @@ +# source: data.s +# ld: -T sane1.t +# nm: -B -n +# notarget: mmix-* pdp11-* rs6000-*-aix* tic30-*-aout +# mmix symbol sections are wrong, pdp sign extends 16-bit addresses +# rs6000-aix and tic30 don't like empty .text + +#... +0+0004 A s5 +#... +0+0004 A x5 +#... +0+0020 A diff +#... +0+0020 A sum_neg +#... +0+0028 A sum +#... +0+0080 A e2 +#... +0+0090 A prod +#... +0+0100 A e1 +#... +0+19a0 A s6 +#... +0+19a0 A x6 +#... +0+8000 A e3 +#... +0+8001 D s2 +#... +0+8001 D x2 +#... +0+8002 D s1 +#... +0+8002 A s4 +#... +0+8002 D x1 +#... +0+8002 A x4 +#... +0+8004 D d1 +#... +0+8007 D s3 +#... +0+8007 D x3 +#... +0+8020 D s_diff +#... +0+8020 D s_sum_neg +#... +0+8024 D d2 +#... +0+8028 D s_sum +#... +0+8090 D s_prod +#... diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sane1.t b/binutils-2.24/ld/testsuite/ld-scripts/sane1.t new file mode 100644 index 0000000..037a62c --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sane1.t @@ -0,0 +1,36 @@ +LD_FEATURE("SANE_EXPR") +e1 = 0x100; +e2 = 0x80; +e3 = e1 * e2; +SECTIONS +{ + . = e3; + .data : + { + d1 = 4; + . += d1 + 5 << 2; + d2 = .; + s_diff = d2 - d1; + s_sum_neg = d2 + -d1; + s_sum = d2 + d1; + s_prod = d2 * d1; + s1 = d1 - 2; + s2 = d2 % 5; + s3 = d2 / 5; + s4 = ABSOLUTE (d1) - 2; + s5 = ABSOLUTE (d2) % 5; + s6 = ABSOLUTE (d2) / 5; + } + /DISCARD/ : {*(*)} + +diff = d2 - d1; +sum_neg = d2 + -d1; +sum = d2 + d1; +prod = d2 * d1; +x1 = d1 - 2; +x2 = d2 % 5; +x3 = d2 / 5; +x4 = ABSOLUTE (d1) - 2; +x5 = ABSOLUTE (d2) % 5; +x6 = ABSOLUTE (d2) / 5; +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/script.exp b/binutils-2.24/ld/testsuite/ld-scripts/script.exp new file mode 100644 index 0000000..41432f9 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/script.exp @@ -0,0 +1,135 @@ +# Test basic linker script functionality +# By Ian Lance Taylor, Cygnus Support +# Copyright 1999-2013 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. + +set testname "script" + +if ![ld_assemble $as $srcdir/$subdir/script.s tmpdir/script.o] { + unresolved $testname + return +} + +proc check_script { } { + global nm + global testname + global nm_output + + if ![ld_nm $nm "" tmpdir/script] { + unresolved $testname + return + } + + if {![info exists nm_output(text_start)] \ + || ![info exists nm_output(text_end)] \ + || ![info exists nm_output(data_start)] \ + || ![info exists nm_output(data_end)]} { + send_log "bad output from nm\n" + verbose "bad output from nm" + fail $testname + return + } + + set passes 1 + set text_end 0x104 + set data_end 0x1004 + + if [istarget *c4x*-*-*] then { + set text_end 0x101 + set data_end 0x1001 + } + + if [istarget *c54x*-*-*] then { + set text_end 0x102 + set data_end 0x1002 + } + + if {$nm_output(text_start) != 0x100} { + send_log "text_start == $nm_output(text_start)\n" + verbose "text_start == $nm_output(text_start)" + set passes 0 + } + + if {$nm_output(text_end) < $text_end \ + || $nm_output(text_end) > 0x110} { + send_log "text_end == $nm_output(text_end)\n" + verbose "text_end == $nm_output(text_end)" + set passes 0 + } + + if {$nm_output(data_start) != 0x1000} { + send_log "data_start == $nm_output(data_start)\n" + verbose "data_start == $nm_output(data_start)" + set passes 0 + } + + if {$nm_output(data_end) < $data_end \ + || $nm_output(data_end) > 0x1010} { + send_log "data_end == $nm_output(data_end)\n" + verbose "data_end == $nm_output(data_end)" + set passes 0 + } + + if { $passes } { + pass $testname + } else { + fail $testname + } +} + +# PE targets need to set the image base to 0 to avoid complications from nm. +set flags "" +if {[istarget "*-*-pe*"] \ + || [istarget "*-*-cygwin*"] \ + || [istarget "*-*-mingw*"] \ + || [istarget "*-*-winnt*"] \ + || [istarget "*-*-nt"] \ + || [istarget "*-*-interix*"] } then { + set flags "--image-base 0" +} + +if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/script.t tmpdir/script.o"] { + fail $testname +} else { + check_script +} + +set testname "MRI script" + +if ![ld_simple_link $ld tmpdir/script "$flags -c $srcdir/$subdir/scriptm.t"] { + fail $testname +} else { + check_script +} + +set testname "MEMORY" + +if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/memory.t tmpdir/script.o"] { + fail $testname +} else { + check_script +} + +set test_script_list [lsort [glob $srcdir/$subdir/region-alias-*.t]] + +foreach test_script $test_script_list { + run_dump_test [string range $test_script 0 end-2] +} + +run_dump_test "align-with-input" diff --git a/binutils-2.24/ld/testsuite/ld-scripts/script.s b/binutils-2.24/ld/testsuite/ld-scripts/script.s new file mode 100644 index 0000000..d7b65b0 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/script.s @@ -0,0 +1,8 @@ + .text + .globl text_symbol +text_symbol: + .long 1 + .data + .globl data_symbol +data_symbol: + .long 2 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/script.t b/binutils-2.24/ld/testsuite/ld-scripts/script.t new file mode 100644 index 0000000..ee7a48a --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/script.t @@ -0,0 +1,16 @@ +SECTIONS +{ + .text 0x100 : { + text_start = .; + *(.text) + *(.pr) + text_end = .; + } + . = 0x1000; + .data : { + data_start = .; + *(.data) + *(.rw) + data_end = .; + } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/scriptm.t b/binutils-2.24/ld/testsuite/ld-scripts/scriptm.t new file mode 100644 index 0000000..57ccae1 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/scriptm.t @@ -0,0 +1,10 @@ +* MRI script +sect .text = $100 ; .text start address +sect .data = 1000h ; .data start address +public text_start = $100 +public text_end = # continuation line + text_start + 4 +public data_start = 1000h +public data_end = data_start + 4 + +load tmpdir/script.o diff --git a/binutils-2.24/ld/testsuite/ld-scripts/section-flags-1.s b/binutils-2.24/ld/testsuite/ld-scripts/section-flags-1.s new file mode 100644 index 0000000..566e3c6 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/section-flags-1.s @@ -0,0 +1,2 @@ + .text + .space 16 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/section-flags-1.t b/binutils-2.24/ld/testsuite/ld-scripts/section-flags-1.t new file mode 100644 index 0000000..3380489 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/section-flags-1.t @@ -0,0 +1,21 @@ +MEMORY +{ + ram (rwx) : ORIGIN = 0x100000, LENGTH = 144M +} + +SECTIONS +{ + .text : + { + INPUT_SECTION_FLAGS (!SHF_TLS) *(.text .text.* .text_* .gnu.linkonce.t.*) + } >ram + + .text_vle : + { + INPUT_SECTION_FLAGS (SHF_MERGE & SHF_STRINGS & SHF_LINK_ORDER) *(.text .text.* .text_* .gnu.linkonce.t.*) + } >ram + .text_other : + { + INPUT_SECTION_FLAGS (SHF_MERGE & !SHF_STRINGS) *(.text .text.* .text_* .gnu.linkonce.t.*) + } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/section-flags-2.s b/binutils-2.24/ld/testsuite/ld-scripts/section-flags-2.s new file mode 100644 index 0000000..566e3c6 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/section-flags-2.s @@ -0,0 +1,2 @@ + .text + .space 16 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/section-flags-2.t b/binutils-2.24/ld/testsuite/ld-scripts/section-flags-2.t new file mode 100644 index 0000000..ca5ae63 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/section-flags-2.t @@ -0,0 +1,12 @@ +MEMORY +{ + ram (rwx) : ORIGIN = 0x100000, LENGTH = 144M +} + +SECTIONS +{ + .text : + { + INPUT_SECTION_FLAGS (!SHF_TLS) *(EXCLUDE_FILE (section-flags-1.o) .text .text.* .text_* .gnu.linkonce.t.*) + } >ram +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/section-flags.exp b/binutils-2.24/ld/testsuite/ld-scripts/section-flags.exp new file mode 100644 index 0000000..0d36f65 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/section-flags.exp @@ -0,0 +1,43 @@ +# Test SECTION_FLAGS in a linker script. +# +# This file is part of the GNU Binutils. +# +# Copyright 2012 Free Software Foundation, Inc. +# +# 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. + +# These tests only work for ELF targets +if {! [is_elf_format]} { + return +} + +set ldcmd $ld +if { [istarget spu*-*-*] } { + set ldcmd "$ldcmd --local-store 0:0" +} + +foreach test {"section-flags-1" "section-flags-2"} { + if ![ld_assemble $as $srcdir/$subdir/$test.s tmpdir/$test.o] { + unresolved $test + } else { + if ![ld_simple_link $ldcmd tmpdir/$test \ + "-T $srcdir/$subdir/$test.t tmpdir/$test.o"] { + fail $test + } else { + pass $test + } + } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/section-match-1.d b/binutils-2.24/ld/testsuite/ld-scripts/section-match-1.d new file mode 100644 index 0000000..c68dbb8 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/section-match-1.d @@ -0,0 +1,16 @@ +#source: section-match-1.s +#ld: -T section-match-1.t +#objdump: -s +#notarget: *-*-osf* *-*-aix* *-*-pe *-*-*aout *-*-*oldld *-*-ecoff *-*-netbsd *-*-vms h8300-*-* tic30-*-* +# This test uses arbitary section names, which are not support by some +# file formts. Also these section names must be present in the +# output, not translated into some other name, eg .text + +.*: file format .* + +#... +Contents of section \.secA: + [0-9a-f]* (01)?0+(01)? .* +Contents of section \.secC: + [0-9a-f]* (02)?0+(02)? .* +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/section-match-1.s b/binutils-2.24/ld/testsuite/ld-scripts/section-match-1.s new file mode 100644 index 0000000..3e32a88 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/section-match-1.s @@ -0,0 +1,5 @@ + .section .sec.foo + .word 1 + + .section .sec..foo + .word 2 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/section-match-1.t b/binutils-2.24/ld/testsuite/ld-scripts/section-match-1.t new file mode 100644 index 0000000..155b3dc --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/section-match-1.t @@ -0,0 +1,16 @@ +SECTIONS +{ + /* .secA should collect all sections with a prefix of ".sec." + except for those with a prefix of ".sec..". */ + .secA : { *(*.sec.[^.]*) } + + /* .secB should be empty because .secA will have taken all of + the potential matches. */ + .secB : { *(*.sec.[!.]*) } + + /* .secC should match any sections with a ".sec.." prefix. */ + .secC : { *(*.sec.*) } + + /* Ignore anything else. */ + /DISCARD/ : { *(*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/section-match.exp b/binutils-2.24/ld/testsuite/ld-scripts/section-match.exp new file mode 100644 index 0000000..bdca8cf --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/section-match.exp @@ -0,0 +1,22 @@ +# Expect script for section regular expressions tests +# Copyright (C) 2010 Free Software Foundation +# +# 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. +# + +run_dump_test section-match-1
\ No newline at end of file diff --git a/binutils-2.24/ld/testsuite/ld-scripts/size-1.d b/binutils-2.24/ld/testsuite/ld-scripts/size-1.d new file mode 100644 index 0000000..641fbca --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/size-1.d @@ -0,0 +1,14 @@ +#source: size-1.s +#ld: -T size-1.t +#objdump: -s + +.*: file format .* + +#... +Contents of section \.text: + [0-9a-f]* (01)?000000(01)? (02)?000000(02)? .* +#... +Contents of section \.data: + [0-9a-f]* (03)?000000(03)? (04)?000000(04)? (05)?000000(05)? 00000000 .* + [0-9a-f]* (20)?000000(20)? (18)?000000(18)? .* +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/size-1.s b/binutils-2.24/ld/testsuite/ld-scripts/size-1.s new file mode 100644 index 0000000..7f5a5fd --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/size-1.s @@ -0,0 +1,7 @@ + .text + .long 1,2 + .p2align 5 + + .data + .long 3,4,5 + .p2align 4 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/size-1.t b/binutils-2.24/ld/testsuite/ld-scripts/size-1.t new file mode 100644 index 0000000..bb48665 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/size-1.t @@ -0,0 +1,10 @@ +SECTIONS +{ + . = 0x1000 + SIZEOF_HEADERS; + .text ALIGN (0x20) : { *(.text) } + .data 0x2000 : { + *(.data) + LONG (SIZEOF (.text)) + LONG (SIZEOF (.data)) + } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/size-2.d b/binutils-2.24/ld/testsuite/ld-scripts/size-2.d new file mode 100644 index 0000000..c925673 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/size-2.d @@ -0,0 +1,18 @@ +#source: size-2.s +#ld: -T size-2.t +#readelf: -l --wide +#xfail: "hppa64-*-*" "v850*-*-*" + +#... +Program Headers: + +Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg +Align + +PHDR +0x[0-9a-f]+ 0x0+0000 0x0+0000 0x[0-9a-f]+ 0x[0-9a-f]+ R +0x[0-9a-f]+ +#... + +LOAD +0x[0-9a-f]+ 0x0+0100 0x0+0100 0x0+0030 0x0+0030 R E +0x[0-9a-f]+ + +TLS +0x[0-9a-f]+ 0x0+0108 0x0+0108 0x0+0014 0x0+002c R +0x[0-9a-f]+ + + Section to Segment mapping: + +Segment Sections\.\.\. + +00 .* + +01.*\.text.*\.tdata.* + +02.*\.tdata.* diff --git a/binutils-2.24/ld/testsuite/ld-scripts/size-2.s b/binutils-2.24/ld/testsuite/ld-scripts/size-2.s new file mode 100644 index 0000000..6b10250 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/size-2.s @@ -0,0 +1,8 @@ + .text + .long 1,2 + + .section .tdata + .long 6,7,8,9,10 + + .section .tbss + .long 0,0,0,0,0,0 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/size-2.t b/binutils-2.24/ld/testsuite/ld-scripts/size-2.t new file mode 100644 index 0000000..e67b3fa --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/size-2.t @@ -0,0 +1,21 @@ +PHDRS +{ + header PT_PHDR FILEHDR PHDRS ; + + image PT_LOAD FLAGS (5); + tls PT_TLS FLAGS (4); + +} +SECTIONS +{ + .text 0x100 : { *(.text) } :image + .tdata : { *(.tdata) } :image :tls + .tbss : { *(.tbss) } :image : tls + .map : { + LONG (SIZEOF (.text)) + LONG (SIZEOF (.data)) + LONG (SIZEOF (.bss)) + LONG (SIZEOF (.tdata)) + LONG (SIZEOF (.tbss)) + } :image +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/size.exp b/binutils-2.24/ld/testsuite/ld-scripts/size.exp new file mode 100644 index 0000000..1d59158 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/size.exp @@ -0,0 +1,41 @@ +# Expect script for SIZEOF tests +# Copyright (C) 2004, 2005, 2007 Free Software Foundation +# +# 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. +# + +# AIX maps .text and .data to other sections. +# a.out objdump displays the file header inside the text segment, +# confusing run_dump_test. + +if {[istarget "rs6000-*-aix*"] || [is_aout_format]} { + unsupported size-1 + unsupported size-2 + return +} + +run_dump_test size-1 + +# size-2 only works on ELF targets. +# MIPS inserts a REGINFO PHDR +if {![is_elf_format] || [istarget "mips*-*-*"]} { + unsupported size-2 + return +} + +run_dump_test size-2 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sizeof.exp b/binutils-2.24/ld/testsuite/ld-scripts/sizeof.exp new file mode 100644 index 0000000..ed5d191 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sizeof.exp @@ -0,0 +1,74 @@ +# Test SIZEOF in a linker script. +# By Ian Lance Taylor, Cygnus Support +# Based on a bug report from anders.blomdell@control.lth.se. +# Copyright 2001, 2005, 2007 +# 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. + +set testname "SIZEOF" + +if ![ld_assemble $as $srcdir/$subdir/sizeof.s tmpdir/sizeof.o] { + unresolved $testname + return +} + +if ![ld_simple_link $ld tmpdir/sizeof "-T $srcdir/$subdir/sizeof.t tmpdir/sizeof.o"] { + fail $testname + return +} + +if ![ld_nm $nm "" tmpdir/sizeof] { + unresolved $testname + return +} + +if {![info exists nm_output(text_start)] \ + || ![info exists nm_output(text_end)] \ + || ![info exists nm_output(data_start)] \ + || ![info exists nm_output(data_end)] \ + || ![info exists nm_output(sizeof_text)] \ + || ![info exists nm_output(sizeof_data)]} { + send_log "bad output from nm\n" + verbose "bad output from nm" + fail $testname + return +} + +if {$nm_output(text_end) - $nm_output(text_start) != $nm_output(sizeof_text)} { + send_log "text_end - text_start != sizeof_text\n" + verbose "text_end - text_start != sizeof_text" + fail $testname + return +} + +if {$nm_output(data_end) - $nm_output(data_start) != $nm_output(sizeof_data)} { + send_log "data_end - data_start != sizeof_data\n" + verbose "data_end - data_start != sizeof_data" + fail $testname + return +} + +if {$nm_output(sizeof_text) != $nm_output(sizeof_data)} { + send_log "sizeof_text != sizeof_data\n" + verbose "sizeof_text != sizeof_data" + fail $testname + return +} + +pass $testname diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sizeof.s b/binutils-2.24/ld/testsuite/ld-scripts/sizeof.s new file mode 100644 index 0000000..e221ca3 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sizeof.s @@ -0,0 +1 @@ + .space 16 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sizeof.t b/binutils-2.24/ld/testsuite/ld-scripts/sizeof.t new file mode 100644 index 0000000..6244a37 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sizeof.t @@ -0,0 +1,17 @@ +SECTIONS { + .text : + { + text_start = .; + tmpdir/sizeof.o + text_end = .; + } + .data : + { + data_start = .; + . = . + SIZEOF(.text); + data_end = .; + } +} + +sizeof_text = SIZEOF(.text); +sizeof_data = SIZEOF(.data); diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort.exp b/binutils-2.24/ld/testsuite/ld-scripts/sort.exp new file mode 100644 index 0000000..47950a7 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort.exp @@ -0,0 +1,40 @@ +# Test SORT_BY_NAME/SORT_BY_ALIGNMENT/SORT in a linker script. +# By H.J. Lu <hongjiu.lu@intel.com> +# Copyright 2004, 2005, 2007 +# 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. + +# FIXME: The expected outputs are correct only for ELF. +if ![is_elf_format] { + return +} + +# The h8300 port issues a warning message for +# new sections created without atrributes. +if [istarget "h8300-*-*"] { + return +} + +load_lib ld-lib.exp + +set sort_test_list [lsort [glob -nocomplain $srcdir/$subdir/sort*.d]] +for { set i 0 } { $i < [llength $sort_test_list] } { incr i } { + verbose [file rootname [lindex $sort_test_list $i]] + run_dump_test [file rootname [lindex $sort_test_list $i]] +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort.t b/binutils-2.24/ld/testsuite/ld-scripts/sort.t new file mode 100644 index 0000000..c53481f --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort.t @@ -0,0 +1,5 @@ +SECTIONS +{ + .text : {*(.text .text.*)} + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a-1.d b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a-1.d new file mode 100644 index 0000000..325193c --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a-1.d @@ -0,0 +1,14 @@ +#source: sort_b_a-1.s +#ld: -T sort.t --sort-section alignment +#name: --sort-section alignment +#nm: -n + +#... +0[0-9a-f]* t text3 +#... +0[0-9a-f]* t text1 +#... +0[0-9a-f]* t text +#... +0[0-9a-f]* t text2 +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a-1.s b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a-1.s new file mode 100644 index 0000000..87d3613 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a-1.s @@ -0,0 +1,16 @@ + .section .text.2 + .p2align 3 +text2: + .long 0 + .section .text.3 + .p2align 6 +text3: + .long 0 + .section .text.1 + .p2align 5 +text1: + .long 0 + .text +text: + .p2align 4 + .long 0 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a.d b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a.d new file mode 100644 index 0000000..0f55808 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a.d @@ -0,0 +1,14 @@ +#source: sort_b_a.s +#ld: -T sort_b_a.t +#name: SORT_BY_ALIGNMENT +#nm: -n + +#... +0[0-9a-f]* t text3 +#... +0[0-9a-f]* t text1 +#... +0[0-9a-f]* t text +#... +0[0-9a-f]* t text2 +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a.s b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a.s new file mode 100644 index 0000000..7b3851f --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a.s @@ -0,0 +1,16 @@ + .section .text2 + .p2align 3 +text2: + .long 0 + .section .text3 + .p2align 6 +text3: + .long 0 + .section .text1 + .p2align 5 +text1: + .long 0 + .text +text: + .p2align 4 + .long 0 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a.t b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a.t new file mode 100644 index 0000000..cbfd3c3 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a.t @@ -0,0 +1,5 @@ +SECTIONS +{ + .text : {*(SORT_BY_ALIGNMENT(.text*))} + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_a-1.d b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_a-1.d new file mode 100644 index 0000000..930f748 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_a-1.d @@ -0,0 +1,23 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_a_a.t +#name: SORT_BY_ALIGNMENT(SORT_BY_ALIGNMENT()) +#nm: -n + +#... +0[0-9a-f]* t text3b +#... +0[0-9a-f]* t text3a +#... +0[0-9a-f]* t text1a +#... +0[0-9a-f]* t text1b +#... +0[0-9a-f]* t texta +#... +0[0-9a-f]* t textb +#... +0[0-9a-f]* t text2a +#... +0[0-9a-f]* t text2b +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_a-2.d b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_a-2.d new file mode 100644 index 0000000..3e7d158 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_a-2.d @@ -0,0 +1,23 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_a_a.t --sort-section alignment +#name: SORT_BY_ALIGNMENT(SORT_BY_ALIGNMENT()) --sort-section alignment +#nm: -n + +#... +0[0-9a-f]* t text3b +#... +0[0-9a-f]* t text3a +#... +0[0-9a-f]* t text1a +#... +0[0-9a-f]* t text1b +#... +0[0-9a-f]* t texta +#... +0[0-9a-f]* t textb +#... +0[0-9a-f]* t text2a +#... +0[0-9a-f]* t text2b +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_a-3.d b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_a-3.d new file mode 100644 index 0000000..b1b0600 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_a-3.d @@ -0,0 +1,23 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_a_a.t --sort-section name +#name: SORT_BY_ALIGNMENT(SORT_BY_ALIGNMENT()) --sort-section name +#nm: -n + +#... +0[0-9a-f]* t text3b +#... +0[0-9a-f]* t text1a +#... +0[0-9a-f]* t text1b +#... +0[0-9a-f]* t text3a +#... +0[0-9a-f]* t texta +#... +0[0-9a-f]* t textb +#... +0[0-9a-f]* t text2a +#... +0[0-9a-f]* t text2b +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_a.t b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_a.t new file mode 100644 index 0000000..359cdff --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_a.t @@ -0,0 +1,5 @@ +SECTIONS +{ + .text : {*(SORT_BY_ALIGNMENT(SORT_BY_ALIGNMENT(.text*)))} + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_n-1.d b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_n-1.d new file mode 100644 index 0000000..dd5c613 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_n-1.d @@ -0,0 +1,23 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_a_n.t +#name: SORT_BY_ALIGNMENT(SORT_BY_NAME()) +#nm: -n + +#... +0[0-9a-f]* t text3b +#... +0[0-9a-f]* t text1a +#... +0[0-9a-f]* t text1b +#... +0[0-9a-f]* t text3a +#... +0[0-9a-f]* t texta +#... +0[0-9a-f]* t textb +#... +0[0-9a-f]* t text2a +#... +0[0-9a-f]* t text2b +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_n-2.d b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_n-2.d new file mode 100644 index 0000000..f87ddd5 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_n-2.d @@ -0,0 +1,23 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_a_n.t --sort-section name +#name: SORT_BY_ALIGNMENT(SORT_BY_NAME()) --sort-section name +#nm: -n + +#... +0[0-9a-f]* t text3b +#... +0[0-9a-f]* t text1a +#... +0[0-9a-f]* t text1b +#... +0[0-9a-f]* t text3a +#... +0[0-9a-f]* t texta +#... +0[0-9a-f]* t textb +#... +0[0-9a-f]* t text2a +#... +0[0-9a-f]* t text2b +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_n-3.d b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_n-3.d new file mode 100644 index 0000000..bf7ee4e --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_n-3.d @@ -0,0 +1,23 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_a_n.t --sort-section alignment +#name: SORT_BY_ALIGNMENT(SORT_BY_NAME()) --sort-section alignment +#nm: -n + +#... +0[0-9a-f]* t text3b +#... +0[0-9a-f]* t text1a +#... +0[0-9a-f]* t text1b +#... +0[0-9a-f]* t text3a +#... +0[0-9a-f]* t texta +#... +0[0-9a-f]* t textb +#... +0[0-9a-f]* t text2a +#... +0[0-9a-f]* t text2b +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_n.t b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_n.t new file mode 100644 index 0000000..04c3917 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_a_n.t @@ -0,0 +1,5 @@ +SECTIONS +{ + .text : {*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.text*)))} + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n-1.d b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n-1.d new file mode 100644 index 0000000..76d60b6 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n-1.d @@ -0,0 +1,14 @@ +#source: sort_b_n-1.s +#ld: -T sort.t --sort-section name +#name: --sort-section name +#nm: -n + +#... +0[0-9a-f]* t text +#... +0[0-9a-f]* t text1 +#... +0[0-9a-f]* t text2 +#... +0[0-9a-f]* t text3 +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n-1.s b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n-1.s new file mode 100644 index 0000000..5a49170 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n-1.s @@ -0,0 +1,12 @@ + .section .text.2 +text2: + .long 0 + .section .text.3 +text3: + .long 0 + .section .text.1 +text1: + .long 0 + .text +text: + .long 0 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n.d b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n.d new file mode 100644 index 0000000..5ef07b2 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n.d @@ -0,0 +1,14 @@ +#source: sort_b_n.s +#ld: -T sort_b_n.t +#name: SORT_BY_NAME +#nm: -n + +#... +0[0-9a-f]* t text +#... +0[0-9a-f]* t text1 +#... +0[0-9a-f]* t text2 +#... +0[0-9a-f]* t text3 +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n.s b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n.s new file mode 100644 index 0000000..c99d75c --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n.s @@ -0,0 +1,12 @@ + .section .text2 +text2: + .long 0 + .section .text3 +text3: + .long 0 + .section .text1 +text1: + .long 0 + .text +text: + .long 0 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n.t b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n.t new file mode 100644 index 0000000..26c2b6e --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n.t @@ -0,0 +1,5 @@ +SECTIONS +{ + .text : {*(SORT_BY_NAME(.text*))} + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_a-1.d b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_a-1.d new file mode 100644 index 0000000..22d6848 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_a-1.d @@ -0,0 +1,23 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_n_a.t +#name: SORT_BY_NAME(SORT_BY_ALIGNMENT()) +#nm: -n + +#... +0[0-9a-f]* t texta +#... +0[0-9a-f]* t textb +#... +0[0-9a-f]* t text1a +#... +0[0-9a-f]* t text1b +#... +0[0-9a-f]* t text2a +#... +0[0-9a-f]* t text2b +#... +0[0-9a-f]* t text3b +#... +0[0-9a-f]* t text3a +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_a-2.d b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_a-2.d new file mode 100644 index 0000000..4c9d8fe --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_a-2.d @@ -0,0 +1,23 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_n_a.t --sort-section name +#name: SORT_BY_NAME(SORT_BY_ALIGNMENT()) --sort-section alignment +#nm: -n + +#... +0[0-9a-f]* t texta +#... +0[0-9a-f]* t textb +#... +0[0-9a-f]* t text1a +#... +0[0-9a-f]* t text1b +#... +0[0-9a-f]* t text2a +#... +0[0-9a-f]* t text2b +#... +0[0-9a-f]* t text3b +#... +0[0-9a-f]* t text3a +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_a-3.d b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_a-3.d new file mode 100644 index 0000000..6657046 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_a-3.d @@ -0,0 +1,23 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_n_a.t --sort-section alignment +#name: SORT_BY_NAME(SORT_BY_ALIGNMENT()) --sort-section alignment +#nm: -n + +#... +0[0-9a-f]* t texta +#... +0[0-9a-f]* t textb +#... +0[0-9a-f]* t text1a +#... +0[0-9a-f]* t text1b +#... +0[0-9a-f]* t text2a +#... +0[0-9a-f]* t text2b +#... +0[0-9a-f]* t text3b +#... +0[0-9a-f]* t text3a +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_a.t b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_a.t new file mode 100644 index 0000000..49cbdd3 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_a.t @@ -0,0 +1,5 @@ +SECTIONS +{ + .text : {*(SORT_BY_NAME(SORT_BY_ALIGNMENT(.text*)))} + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_n-1.d b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_n-1.d new file mode 100644 index 0000000..b2b2dbe --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_n-1.d @@ -0,0 +1,23 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_n_n.t +#name: SORT_BY_NAME(SORT_BY_NAME()) +#nm: -n + +#... +0[0-9a-f]* t texta +#... +0[0-9a-f]* t textb +#... +0[0-9a-f]* t text1a +#... +0[0-9a-f]* t text1b +#... +0[0-9a-f]* t text2a +#... +0[0-9a-f]* t text2b +#... +0[0-9a-f]* t text3a +#... +0[0-9a-f]* t text3b +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_n-2.d b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_n-2.d new file mode 100644 index 0000000..15b66e4 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_n-2.d @@ -0,0 +1,23 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_n_n.t --sort-section name +#name: SORT_BY_NAME(SORT_BY_NAME()) --sort-section name +#nm: -n + +#... +0[0-9a-f]* t texta +#... +0[0-9a-f]* t textb +#... +0[0-9a-f]* t text1a +#... +0[0-9a-f]* t text1b +#... +0[0-9a-f]* t text2a +#... +0[0-9a-f]* t text2b +#... +0[0-9a-f]* t text3a +#... +0[0-9a-f]* t text3b +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_n-3.d b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_n-3.d new file mode 100644 index 0000000..b99f7e1 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_n-3.d @@ -0,0 +1,23 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_n_n.t --sort-section alignment +#name: SORT_BY_NAME(SORT_BY_NAME()) --sort-section alignment +#nm: -n + +#... +0[0-9a-f]* t texta +#... +0[0-9a-f]* t textb +#... +0[0-9a-f]* t text1a +#... +0[0-9a-f]* t text1b +#... +0[0-9a-f]* t text2a +#... +0[0-9a-f]* t text2b +#... +0[0-9a-f]* t text3b +#... +0[0-9a-f]* t text3a +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_n.t b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_n.t new file mode 100644 index 0000000..b4eabfe --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_b_n_n.t @@ -0,0 +1,5 @@ +SECTIONS +{ + .text : {*(SORT_BY_NAME(SORT_BY_NAME(.text*)))} + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_n_a-a.s b/binutils-2.24/ld/testsuite/ld-scripts/sort_n_a-a.s new file mode 100644 index 0000000..77dfc35 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_n_a-a.s @@ -0,0 +1,16 @@ + .section .text2 + .p2align 3 +text2a: + .long 0 + .section .text3 + .p2align 5 +text3a: + .long 0 + .section .text1 + .p2align 5 +text1a: + .long 0 + .text +texta: + .p2align 4 + .long 0 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_n_a-b.s b/binutils-2.24/ld/testsuite/ld-scripts/sort_n_a-b.s new file mode 100644 index 0000000..781ba4e --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_n_a-b.s @@ -0,0 +1,16 @@ + .section .text2 + .p2align 3 +text2b: + .long 0 + .section .text3 + .p2align 6 +text3b: + .long 0 + .section .text1 + .p2align 5 +text1b: + .long 0 + .text +textb: + .p2align 4 + .long 0 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_no-1.d b/binutils-2.24/ld/testsuite/ld-scripts/sort_no-1.d new file mode 100644 index 0000000..c5f5593 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_no-1.d @@ -0,0 +1,14 @@ +#source: sort_b_n.s +#ld: -T sort_no.t +#name: no SORT_BY_NAME/SORT_BY_ALIGNMENT/SORT +#nm: -n + +#... +0[0-9a-f]* t text +#... +0[0-9a-f]* t text2 +#... +0[0-9a-f]* t text3 +#... +0[0-9a-f]* t text1 +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_no-2.d b/binutils-2.24/ld/testsuite/ld-scripts/sort_no-2.d new file mode 100644 index 0000000..e0943d5 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_no-2.d @@ -0,0 +1,14 @@ +#source: sort_b_a.s +#ld: -T sort_no.t +#name: no SORT_BY_NAME/SORT_BY_ALIGNMENT/SORT +#nm: -n + +#... +0[0-9a-f]* t text +#... +0[0-9a-f]* t text2 +#... +0[0-9a-f]* t text3 +#... +0[0-9a-f]* t text1 +#pass diff --git a/binutils-2.24/ld/testsuite/ld-scripts/sort_no.t b/binutils-2.24/ld/testsuite/ld-scripts/sort_no.t new file mode 100644 index 0000000..d797c79 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/sort_no.t @@ -0,0 +1,5 @@ +SECTIONS +{ + .text : {*(.text*)} + /DISCARD/ : { *(.*) } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/weak.exp b/binutils-2.24/ld/testsuite/ld-scripts/weak.exp new file mode 100644 index 0000000..cba6e25 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/weak.exp @@ -0,0 +1,80 @@ +# Test weak symbols. +# By Ian Lance Taylor, Cygnus Solutions. +# Copyright 1999, 2000, 2002, 2004, 2005, 2006, 2007, 2009, 2011 +# 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. + +set testname "weak symbols" + +# This test only works for ELF targets and some PE targets. +# It ought to work for some a.out targets, but it doesn't. +if {! [is_elf_format] && ! [is_pecoff_format]} { + unsupported $testname + return +} + +# Weak symbols are broken for most PE targets. +if {! [istarget i?86-*-*] && ! [istarget sh-*-*]} { + setup_xfail *-*-pe* +} + +# hppa64 and or32 are incredibly broken +setup_xfail hppa64-*-* or32-*-* + +if {! [ld_assemble $as $srcdir/$subdir/weak1.s tmpdir/weak1.o] + || ! [ld_assemble $as $srcdir/$subdir/weak2.s tmpdir/weak2.o]} then { + # It's OK if .weak doesn't work on this target. + unresolved $testname + return +} + +global LDFLAGS +set saved_LDFLAGS "$LDFLAGS" +if [istarget "x86_64-*-mingw*"] then { + set LDFLAGS "$LDFLAGS --image-base 0" +} + +set weak_regexp_big \ +".*Contents of section .text:.*1000 00001008 0000200c 12121212 34343434.*Contents of section .data:.*2000 00001008 0000200c 56565656 78787878.*" + +set weak_regexp_little \ +".*Contents of section .text:.*1000 08100000 0c200000 12121212 34343434.*Contents of section .data:.*2000 08100000 0c200000 56565656 78787878.*" + +if {! [ld_simple_link $ld tmpdir/weak "$flags -T $srcdir/$subdir/weak.t tmpdir/weak1.o tmpdir/weak2.o"] } then { + fail $testname +} else { + if {![is_remote host] && [which $objdump] == 0} then { + unresolved $testname + set LDFLAGS "$saved_LDFLAGS" + return + } + + set exec_output [run_host_cmd "$objdump" "-s tmpdir/weak"] + set exec_output [prune_warnings $exec_output] + verbose -log $exec_output + + if {[regexp $weak_regexp_big $exec_output] \ + || [regexp $weak_regexp_little $exec_output] } then { + pass $testname + } else { + fail $testname + } +} + +set LDFLAGS "$saved_LDFLAGS" diff --git a/binutils-2.24/ld/testsuite/ld-scripts/weak.t b/binutils-2.24/ld/testsuite/ld-scripts/weak.t new file mode 100644 index 0000000..6cd013e --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/weak.t @@ -0,0 +1,12 @@ +SECTIONS +{ + .text 0x1000 : { + tmpdir/weak1.o(.data) + } + .data 0x2000 : { + tmpdir/weak2.o(.data) + } + /DISCARD/ : { + *(*) + } +} diff --git a/binutils-2.24/ld/testsuite/ld-scripts/weak1.s b/binutils-2.24/ld/testsuite/ld-scripts/weak1.s new file mode 100644 index 0000000..26bffbd --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/weak1.s @@ -0,0 +1,11 @@ + .data + .global foo1 + .global sym1 + .weak sym2 +foo1: + .long sym1 + .long sym2 +sym1: + .long 0x12121212 +sym2: + .long 0x34343434 diff --git a/binutils-2.24/ld/testsuite/ld-scripts/weak2.s b/binutils-2.24/ld/testsuite/ld-scripts/weak2.s new file mode 100644 index 0000000..963b229 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-scripts/weak2.s @@ -0,0 +1,11 @@ + .data + .global foo2 + .weak sym1 + .global sym2 +foo2: + .long sym1 + .long sym2 +sym1: + .long 0x56565656 +sym2: + .long 0x78787878 |