aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'ld/testsuite/ld-scripts')
-rw-r--r--ld/testsuite/ld-scripts/align.exp16
-rw-r--r--ld/testsuite/ld-scripts/align2a.d8
-rw-r--r--ld/testsuite/ld-scripts/alignof.exp63
-rw-r--r--ld/testsuite/ld-scripts/alignof.s9
-rw-r--r--ld/testsuite/ld-scripts/alignof.t15
-rw-r--r--ld/testsuite/ld-scripts/assert.t7
-rw-r--r--ld/testsuite/ld-scripts/cross3.t2
-rw-r--r--ld/testsuite/ld-scripts/default-script.exp29
-rw-r--r--ld/testsuite/ld-scripts/default-script.s3
-rw-r--r--ld/testsuite/ld-scripts/default-script.t7
-rw-r--r--ld/testsuite/ld-scripts/default-script1.d9
-rw-r--r--ld/testsuite/ld-scripts/default-script2.d9
-rw-r--r--ld/testsuite/ld-scripts/default-script3.d9
-rw-r--r--ld/testsuite/ld-scripts/default-script4.d9
-rw-r--r--ld/testsuite/ld-scripts/defined.exp11
-rw-r--r--ld/testsuite/ld-scripts/empty-address-1.d8
-rw-r--r--ld/testsuite/ld-scripts/empty-address-1.s5
-rw-r--r--ld/testsuite/ld-scripts/empty-address-1.t11
-rw-r--r--ld/testsuite/ld-scripts/empty-address-2.s5
-rw-r--r--ld/testsuite/ld-scripts/empty-address-2a.d8
-rw-r--r--ld/testsuite/ld-scripts/empty-address-2a.t7
-rw-r--r--ld/testsuite/ld-scripts/empty-address-2b.d8
-rw-r--r--ld/testsuite/ld-scripts/empty-address-2b.t11
-rw-r--r--ld/testsuite/ld-scripts/empty-address-3.s5
-rw-r--r--ld/testsuite/ld-scripts/empty-address-3a.d8
-rw-r--r--ld/testsuite/ld-scripts/empty-address-3a.t10
-rw-r--r--ld/testsuite/ld-scripts/empty-address-3b.d8
-rw-r--r--ld/testsuite/ld-scripts/empty-address-3b.t11
-rw-r--r--ld/testsuite/ld-scripts/empty-address-3c.d10
-rw-r--r--ld/testsuite/ld-scripts/empty-address-3c.t11
-rw-r--r--ld/testsuite/ld-scripts/empty-address.exp25
-rw-r--r--ld/testsuite/ld-scripts/empty-orphan.exp6
-rw-r--r--ld/testsuite/ld-scripts/empty-orphan.t2
-rw-r--r--ld/testsuite/ld-scripts/expr.exp20
-rw-r--r--ld/testsuite/ld-scripts/expr1.d2
-rw-r--r--ld/testsuite/ld-scripts/expr1.s2
-rw-r--r--ld/testsuite/ld-scripts/expr1.t12
-rw-r--r--ld/testsuite/ld-scripts/extern.exp68
-rw-r--r--ld/testsuite/ld-scripts/extern.s1
-rw-r--r--ld/testsuite/ld-scripts/extern.t14
-rw-r--r--ld/testsuite/ld-scripts/overlay-size.t1
-rw-r--r--ld/testsuite/ld-scripts/phdrs.exp10
-rw-r--r--ld/testsuite/ld-scripts/phdrs2.exp8
-rw-r--r--ld/testsuite/ld-scripts/provide.exp10
-rw-r--r--ld/testsuite/ld-scripts/script.exp6
-rw-r--r--ld/testsuite/ld-scripts/sort.t5
-rw-r--r--ld/testsuite/ld-scripts/sort_b_a-1.d9
-rw-r--r--ld/testsuite/ld-scripts/sort_b_a-1.s16
-rw-r--r--ld/testsuite/ld-scripts/sort_b_n-1.d9
-rw-r--r--ld/testsuite/ld-scripts/sort_b_n-1.s12
-rw-r--r--ld/testsuite/ld-scripts/weak.exp12
51 files changed, 559 insertions, 23 deletions
diff --git a/ld/testsuite/ld-scripts/align.exp b/ld/testsuite/ld-scripts/align.exp
index 43369d0b21ee..8c97d3bcc805 100644
--- a/ld/testsuite/ld-scripts/align.exp
+++ b/ld/testsuite/ld-scripts/align.exp
@@ -1,6 +1,6 @@
# Test ALIGN in a linker script.
# By Nathan Sidwell, CodeSourcery LLC
-# Copyright 2004, 2005
+# Copyright 2004, 2005, 2006
# Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify
@@ -29,13 +29,20 @@ if ![ld_assemble $as $srcdir/$subdir/align.s tmpdir/align.o] {
return
}
-# Doesn't work on PECOFF, appears to be a genuine bug
-if [is_pecoff_format] {
+# Doesn't work on PECOFF, appears to be a genuine bug.
+# 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"
+} else {
+ if [is_pecoff_format] {
global target_triplet
setup_xfail $target_triplet
+ }
}
-if ![ld_simple_link $ld tmpdir/align "-T $srcdir/$subdir/align.t tmpdir/align.o"] {
+if ![ld_simple_link $ld tmpdir/align "$LDFLAGS -T $srcdir/$subdir/align.t tmpdir/align.o"] {
fail $testname
} else {
pass $testname
@@ -50,3 +57,4 @@ if ![is_aout_format] {
run_dump_test align2b
}
run_dump_test align2c
+set LDFLAGS "$saved_LDFLAGS"
diff --git a/ld/testsuite/ld-scripts/align2a.d b/ld/testsuite/ld-scripts/align2a.d
index d45cf0e631ba..96237dd72f75 100644
--- a/ld/testsuite/ld-scripts/align2a.d
+++ b/ld/testsuite/ld-scripts/align2a.d
@@ -5,8 +5,8 @@
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
+[ ]+0 +\.text +[^ ]* +0+ +0+ .*
+[ ]+CONTENTS, +ALLOC, +LOAD,.* CODE
+[ ]+1 +\.data +[^ ]* +0+10 +0+10 .*
+[ ]+CONTENTS, +ALLOC, +LOAD, +DATA
#pass
diff --git a/ld/testsuite/ld-scripts/alignof.exp b/ld/testsuite/ld-scripts/alignof.exp
new file mode 100644
index 000000000000..0955e7c3f9b0
--- /dev/null
+++ b/ld/testsuite/ld-scripts/alignof.exp
@@ -0,0 +1,63 @@
+# Test ALIGNOF in a linker script.
+# By Nathan Sidwell <nathan@codesourcery.com>
+#
+# This file 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 2 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 targets record section alignment.
+
+if ![is_elf_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/ld/testsuite/ld-scripts/alignof.s b/ld/testsuite/ld-scripts/alignof.s
new file mode 100644
index 000000000000..d440d2ee699a
--- /dev/null
+++ b/ld/testsuite/ld-scripts/alignof.s
@@ -0,0 +1,9 @@
+
+ .text
+ .p2align 6
+ .long 0
+
+ .data
+ .p2align 4
+ .long 0
+
diff --git a/ld/testsuite/ld-scripts/alignof.t b/ld/testsuite/ld-scripts/alignof.t
new file mode 100644
index 000000000000..12411121f167
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/assert.t b/ld/testsuite/ld-scripts/assert.t
index 62aee34ed348..809ff4c3ff4f 100644
--- a/ld/testsuite/ld-scripts/assert.t
+++ b/ld/testsuite/ld-scripts/assert.t
@@ -1,5 +1,10 @@
SECTIONS
{
- .empty : {}
+ .empty : {
+ here = !.;
+ ASSERT (!., "dot is not zero");
+ ASSERT (here, "here is zero");
+ }
ASSERT (!SIZEOF(.empty), "Empty is not empty")
+ /DISCARD/ : { *(.reginfo) }
}
diff --git a/ld/testsuite/ld-scripts/cross3.t b/ld/testsuite/ld-scripts/cross3.t
index 5411b9b68048..5e32bb2fca69 100644
--- a/ld/testsuite/ld-scripts/cross3.t
+++ b/ld/testsuite/ld-scripts/cross3.t
@@ -4,7 +4,7 @@ SECTIONS
{
.text : { *(.text) }
.nocrossrefs : { *(.nocrossrefs) }
- .data : { *(.data) }
+ .data : { *(.data) *(.opd) }
.bss : { *(.bss) *(COMMON) }
/DISCARD/ : { *(*) }
}
diff --git a/ld/testsuite/ld-scripts/default-script.exp b/ld/testsuite/ld-scripts/default-script.exp
new file mode 100644
index 000000000000..e496e9c0c749
--- /dev/null
+++ b/ld/testsuite/ld-scripts/default-script.exp
@@ -0,0 +1,29 @@
+# Test --default-script/-dT
+# Copyright 2007
+# Free Software Foundation, Inc.
+#
+# This file 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 2 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 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]
+}
+
diff --git a/ld/testsuite/ld-scripts/default-script.s b/ld/testsuite/ld-scripts/default-script.s
new file mode 100644
index 000000000000..494fb622af41
--- /dev/null
+++ b/ld/testsuite/ld-scripts/default-script.s
@@ -0,0 +1,3 @@
+ .text
+text:
+ .long 0
diff --git a/ld/testsuite/ld-scripts/default-script.t b/ld/testsuite/ld-scripts/default-script.t
new file mode 100644
index 000000000000..fc70187cd404
--- /dev/null
+++ b/ld/testsuite/ld-scripts/default-script.t
@@ -0,0 +1,7 @@
+_START = DEFINED(_START) ? _START : 0x9000000;
+SECTIONS
+{
+ . = _START;
+ .text : {*(.text)}
+ /DISCARD/ : {*(*)}
+}
diff --git a/ld/testsuite/ld-scripts/default-script1.d b/ld/testsuite/ld-scripts/default-script1.d
new file mode 100644
index 000000000000..1a709baaf192
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/default-script2.d b/ld/testsuite/ld-scripts/default-script2.d
new file mode 100644
index 000000000000..c29d733da92e
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/default-script3.d b/ld/testsuite/ld-scripts/default-script3.d
new file mode 100644
index 000000000000..b41dcbf0a3b9
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/default-script4.d b/ld/testsuite/ld-scripts/default-script4.d
new file mode 100644
index 000000000000..ec097d633bca
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/defined.exp b/ld/testsuite/ld-scripts/defined.exp
index dff238b1f892..13e8d5a67a1f 100644
--- a/ld/testsuite/ld-scripts/defined.exp
+++ b/ld/testsuite/ld-scripts/defined.exp
@@ -1,6 +1,6 @@
# Test DEFINED in a linker script.
# By Ian Lance Taylor, Cygnus Support.
-# Copyright 2001, 2003
+# Copyright 2001, 2003. 2006
# Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify
@@ -25,7 +25,13 @@ if ![ld_assemble $as $srcdir/$subdir/defined.s tmpdir/def.o] {
return
}
-if ![ld_simple_link $ld tmpdir/def "-T $srcdir/$subdir/defined.t tmpdir/def.o"] {
+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] {
@@ -57,3 +63,4 @@ if ![ld_simple_link $ld tmpdir/def "-T $srcdir/$subdir/defined.t tmpdir/def.o"]
set prms_id 0
run_dump_test "defined2"
run_dump_test "defined3"
+set LDFLAGS "$saved_LDFLAGS"
diff --git a/ld/testsuite/ld-scripts/empty-address-1.d b/ld/testsuite/ld-scripts/empty-address-1.d
new file mode 100644
index 000000000000..99fac1e58b59
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-1.d
@@ -0,0 +1,8 @@
+#ld: -T empty-address-1.t
+#nm: -n
+#...
+0+0 T _start
+#...
+0+2000000 A __data_end
+0+2000000 [ADT] __data_start
+#pass
diff --git a/ld/testsuite/ld-scripts/empty-address-1.s b/ld/testsuite/ld-scripts/empty-address-1.s
new file mode 100644
index 000000000000..c5cc1a596c8a
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/empty-address-1.t b/ld/testsuite/ld-scripts/empty-address-1.t
new file mode 100644
index 000000000000..57a8bed27711
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/empty-address-2.s b/ld/testsuite/ld-scripts/empty-address-2.s
new file mode 100644
index 000000000000..79f58eacc343
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-2.s
@@ -0,0 +1,5 @@
+ .text
+ .global _start
+_start:
+ .long __data_end
+ .p2align 4
diff --git a/ld/testsuite/ld-scripts/empty-address-2a.d b/ld/testsuite/ld-scripts/empty-address-2a.d
new file mode 100644
index 000000000000..d831d5ffd1ab
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-2a.d
@@ -0,0 +1,8 @@
+#source: empty-address-2.s
+#ld: -Ttext 0x0000000 -Tdata 0x2000000 -T empty-address-2a.t
+#nm: -n
+#...
+0+0 T _start
+#...
+0+10 A __data_end
+#pass
diff --git a/ld/testsuite/ld-scripts/empty-address-2a.t b/ld/testsuite/ld-scripts/empty-address-2a.t
new file mode 100644
index 000000000000..6a40ad8b7c43
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-2a.t
@@ -0,0 +1,7 @@
+SECTIONS
+{
+ .text : { *(.text) }
+ .data : { *(.data) }
+ __data_end = .;
+ /DISCARD/ : { *(.*) }
+}
diff --git a/ld/testsuite/ld-scripts/empty-address-2b.d b/ld/testsuite/ld-scripts/empty-address-2b.d
new file mode 100644
index 000000000000..514fd68e2609
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-2b.d
@@ -0,0 +1,8 @@
+#source: empty-address-2.s
+#ld: -Ttext 0x0000000 -Tdata 0x2000000 -T empty-address-2b.t
+#nm: -n
+#...
+0+0 T _start
+#...
+0+10 A __data_end
+#pass
diff --git a/ld/testsuite/ld-scripts/empty-address-2b.t b/ld/testsuite/ld-scripts/empty-address-2b.t
new file mode 100644
index 000000000000..dcf264f4a28f
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/empty-address-3.s b/ld/testsuite/ld-scripts/empty-address-3.s
new file mode 100644
index 000000000000..6b07dd434d52
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/empty-address-3a.d b/ld/testsuite/ld-scripts/empty-address-3a.d
new file mode 100644
index 000000000000..bb12c801906b
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-3a.d
@@ -0,0 +1,8 @@
+#source: empty-address-3.s
+#ld: -T empty-address-3a.t
+#nm: -n
+#...
+0+0 T _start
+#...
+0+10 A __data_end
+#pass
diff --git a/ld/testsuite/ld-scripts/empty-address-3a.t b/ld/testsuite/ld-scripts/empty-address-3a.t
new file mode 100644
index 000000000000..2807e71f561f
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/empty-address-3b.d b/ld/testsuite/ld-scripts/empty-address-3b.d
new file mode 100644
index 000000000000..b3e2a4b5ec3a
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address-3b.d
@@ -0,0 +1,8 @@
+#source: empty-address-3.s
+#ld: -T empty-address-3b.t
+#nm: -n
+#...
+0+0 T _start
+#...
+0+10 A __data_end
+#pass
diff --git a/ld/testsuite/ld-scripts/empty-address-3b.t b/ld/testsuite/ld-scripts/empty-address-3b.t
new file mode 100644
index 000000000000..4f213af519ea
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/empty-address-3c.d b/ld/testsuite/ld-scripts/empty-address-3c.d
new file mode 100644
index 000000000000..6001885bc712
--- /dev/null
+++ b/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 A __data_end
+#...
+0+1010 [ADT] __data_start
+#pass
diff --git a/ld/testsuite/ld-scripts/empty-address-3c.t b/ld/testsuite/ld-scripts/empty-address-3c.t
new file mode 100644
index 000000000000..6de519881fed
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/empty-address.exp b/ld/testsuite/ld-scripts/empty-address.exp
new file mode 100644
index 000000000000..556aabae42f2
--- /dev/null
+++ b/ld/testsuite/ld-scripts/empty-address.exp
@@ -0,0 +1,25 @@
+# Make sure that "dot" is updated for empty sections if their addresses
+# are set.
+# Copyright 2006
+# Free Software Foundation, Inc.
+#
+# This file 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 2 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 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/ld/testsuite/ld-scripts/empty-orphan.exp b/ld/testsuite/ld-scripts/empty-orphan.exp
index fa845e03fa45..847e8f4bca6a 100644
--- a/ld/testsuite/ld-scripts/empty-orphan.exp
+++ b/ld/testsuite/ld-scripts/empty-orphan.exp
@@ -1,6 +1,6 @@
# Make sure orphan sections do not lead to huge output files.
# By David Heine, Tensilica, Inc.
-# Copyright 2005
+# Copyright 2005, 2006
# Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify
@@ -22,6 +22,10 @@ if ![is_elf_format] {
return
}
+if { [istarget spu*-*-*] } {
+ set LDFLAGS "--local-store 0:0"
+}
+
set testname "empty-orphan"
run_dump_test empty-orphan
diff --git a/ld/testsuite/ld-scripts/empty-orphan.t b/ld/testsuite/ld-scripts/empty-orphan.t
index 0f717a3f3312..b57e164aa7c7 100644
--- a/ld/testsuite/ld-scripts/empty-orphan.t
+++ b/ld/testsuite/ld-scripts/empty-orphan.t
@@ -17,6 +17,6 @@ SECTIONS
.text : { *(.text) } > text_mem : text_phdr
.data : { *(.data) } > data_mem : data_phdr
.bss : { *(.bss) } > data_mem : data_phdr
- /DISCARD/ : { *(.reginfo) }
+ /DISCARD/ : { *(.reginfo) *(.glue*) }
/* .orphan_data is an orphan */
}
diff --git a/ld/testsuite/ld-scripts/expr.exp b/ld/testsuite/ld-scripts/expr.exp
new file mode 100644
index 000000000000..43ca1c6c89aa
--- /dev/null
+++ b/ld/testsuite/ld-scripts/expr.exp
@@ -0,0 +1,20 @@
+# Test ALIGN in a linker script.
+# By Nathan Sidwell, CodeSourcery LLC
+# Copyright 2006
+# Free Software Foundation, Inc.
+#
+# This file 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 2 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
diff --git a/ld/testsuite/ld-scripts/expr1.d b/ld/testsuite/ld-scripts/expr1.d
new file mode 100644
index 000000000000..d96dfc1e1c1a
--- /dev/null
+++ b/ld/testsuite/ld-scripts/expr1.d
@@ -0,0 +1,2 @@
+# ld: -T expr1.t
+# error: undefined section .* in expression
diff --git a/ld/testsuite/ld-scripts/expr1.s b/ld/testsuite/ld-scripts/expr1.s
new file mode 100644
index 000000000000..ec0ce903bb10
--- /dev/null
+++ b/ld/testsuite/ld-scripts/expr1.s
@@ -0,0 +1,2 @@
+ .word 0
+
diff --git a/ld/testsuite/ld-scripts/expr1.t b/ld/testsuite/ld-scripts/expr1.t
new file mode 100644
index 000000000000..e0810ba07ed4
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/extern.exp b/ld/testsuite/ld-scripts/extern.exp
new file mode 100644
index 000000000000..a613a757eee3
--- /dev/null
+++ b/ld/testsuite/ld-scripts/extern.exp
@@ -0,0 +1,68 @@
+# Test EXTERN in a linker script.
+# By Nathan Sidwell, CodeSourcery LLC
+# Copyright 2007
+# Free Software Foundation, Inc.
+#
+# This file 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 2 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/ld/testsuite/ld-scripts/extern.s b/ld/testsuite/ld-scripts/extern.s
new file mode 100644
index 000000000000..09cc1e1f7cd8
--- /dev/null
+++ b/ld/testsuite/ld-scripts/extern.s
@@ -0,0 +1 @@
+ .text
diff --git a/ld/testsuite/ld-scripts/extern.t b/ld/testsuite/ld-scripts/extern.t
new file mode 100644
index 000000000000..b2a012a322c1
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/overlay-size.t b/ld/testsuite/ld-scripts/overlay-size.t
index f7ffbbbd7422..53f857d6966b 100644
--- a/ld/testsuite/ld-scripts/overlay-size.t
+++ b/ld/testsuite/ld-scripts/overlay-size.t
@@ -54,4 +54,5 @@ SECTIONS
} > DATAMEM AT > LOADMEM
. = 0x8000;
+ /DISCARD/ : { *(.reginfo) }
}
diff --git a/ld/testsuite/ld-scripts/phdrs.exp b/ld/testsuite/ld-scripts/phdrs.exp
index 67af6ad9b6aa..7dca55505a07 100644
--- a/ld/testsuite/ld-scripts/phdrs.exp
+++ b/ld/testsuite/ld-scripts/phdrs.exp
@@ -1,6 +1,6 @@
# Test PHDRS in a linker script.
# By Ian Lance Taylor, Cygnus Support.
-# Copyright 1999, 2000, 2001, 2002, 2003
+# Copyright 1999, 2000, 2001, 2002, 2003, 2006
# Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify
@@ -26,6 +26,11 @@ if ![is_elf_format] {
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
@@ -40,7 +45,8 @@ if [is_elf64 tmpdir/phdrs.o] {
".*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-.*"
}
-if ![ld_simple_link $ld tmpdir/phdrs "-T $srcdir/$subdir/phdrs.t tmpdir/phdrs.o"] {
+set ldopt "$ldopt -T $srcdir/$subdir/phdrs.t tmpdir/phdrs.o"
+if ![ld_simple_link $ld tmpdir/phdrs $ldopt] {
fail $testname
} else {
if {[which $objdump] == 0} {
diff --git a/ld/testsuite/ld-scripts/phdrs2.exp b/ld/testsuite/ld-scripts/phdrs2.exp
index 5fbc2fa45369..8c41ffe31799 100644
--- a/ld/testsuite/ld-scripts/phdrs2.exp
+++ b/ld/testsuite/ld-scripts/phdrs2.exp
@@ -36,6 +36,11 @@ if { [istarget *-*-linux*aout*] \
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
@@ -44,7 +49,8 @@ if ![ld_assemble $as $srcdir/$subdir/phdrs2.s tmpdir/phdrs2.o] {
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.*"
-if ![ld_simple_link $ld tmpdir/phdrs2 "-T $srcdir/$subdir/phdrs2.t tmpdir/phdrs2.o"] {
+set ldopt "$ldopt -T $srcdir/$subdir/phdrs2.t tmpdir/phdrs2.o"
+if ![ld_simple_link $ld tmpdir/phdrs2 $ldopt] {
fail $testname
} else {
if {[which $objdump] == 0} {
diff --git a/ld/testsuite/ld-scripts/provide.exp b/ld/testsuite/ld-scripts/provide.exp
index 7e2c0e7e01d6..46915978acd9 100644
--- a/ld/testsuite/ld-scripts/provide.exp
+++ b/ld/testsuite/ld-scripts/provide.exp
@@ -1,6 +1,6 @@
# Test PROVIDE in a linker script.
# By Nathan Sidwell, CodeSourcery LLC
-# Copyright 2004
+# Copyright 2004, 2006
# Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify
@@ -29,7 +29,15 @@ if {[istarget "rs6000-*-aix*"] || [is_aout_format]} {
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/ld/testsuite/ld-scripts/script.exp b/ld/testsuite/ld-scripts/script.exp
index bf7b1b1dc916..6bb8c9cee27a 100644
--- a/ld/testsuite/ld-scripts/script.exp
+++ b/ld/testsuite/ld-scripts/script.exp
@@ -1,6 +1,6 @@
# Test basic linker script functionality
# By Ian Lance Taylor, Cygnus Support
-# Copyright 1999, 2000, 2001, 2002, 2004
+# Copyright 1999, 2000, 2001, 2002, 2004, 2006
# Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify
@@ -95,7 +95,7 @@ proc check_script { } {
set flags ""
if {[istarget "*-*-pe*"] \
|| [istarget "*-*-cygwin*"] \
- || [istarget "*-*-mingw32*"] \
+ || [istarget "*-*-mingw*"] \
|| [istarget "*-*-winnt*"] \
|| [istarget "*-*-nt"] \
|| [istarget "*-*-interix*"] } then {
@@ -123,5 +123,3 @@ if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/memory.t tmpdir
} else {
check_script
}
-
-
diff --git a/ld/testsuite/ld-scripts/sort.t b/ld/testsuite/ld-scripts/sort.t
new file mode 100644
index 000000000000..c53481f2f3de
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort.t
@@ -0,0 +1,5 @@
+SECTIONS
+{
+ .text : {*(.text .text.*)}
+ /DISCARD/ : { *(.*) }
+}
diff --git a/ld/testsuite/ld-scripts/sort_b_a-1.d b/ld/testsuite/ld-scripts/sort_b_a-1.d
new file mode 100644
index 000000000000..eaa917de570a
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort_b_a-1.d
@@ -0,0 +1,9 @@
+#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
diff --git a/ld/testsuite/ld-scripts/sort_b_a-1.s b/ld/testsuite/ld-scripts/sort_b_a-1.s
new file mode 100644
index 000000000000..87d3613f885e
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/sort_b_n-1.d b/ld/testsuite/ld-scripts/sort_b_n-1.d
new file mode 100644
index 000000000000..42bdcf91aa29
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort_b_n-1.d
@@ -0,0 +1,9 @@
+#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
diff --git a/ld/testsuite/ld-scripts/sort_b_n-1.s b/ld/testsuite/ld-scripts/sort_b_n-1.s
new file mode 100644
index 000000000000..5a49170d46b9
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/weak.exp b/ld/testsuite/ld-scripts/weak.exp
index 925c812c7e01..c70bbf2627c2 100644
--- a/ld/testsuite/ld-scripts/weak.exp
+++ b/ld/testsuite/ld-scripts/weak.exp
@@ -1,6 +1,6 @@
# Test weak symbols.
# By Ian Lance Taylor, Cygnus Solutions.
-# Copyright 1999, 2000, 2002, 2004
+# Copyright 1999, 2000, 2002, 2004, 2006
# Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify
@@ -29,6 +29,7 @@ if {! [is_elf_format] && ! [is_pecoff_format]} {
# Weak symbols are broken for non-i386 PE targets.
if {! [istarget i?86-*-*]} {
setup_xfail *-*-pe*
+ setup_xfail x86_64-*-mingw*
}
# hppa64 and or32 are incredibly broken
@@ -41,6 +42,12 @@ if {! [ld_assemble $as $srcdir/$subdir/weak1.s tmpdir/weak1.o]
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.*"
@@ -52,6 +59,7 @@ if {! [ld_simple_link $ld tmpdir/weak "$flags -T $srcdir/$subdir/weak.t tmpdir/w
} else {
if {[which $objdump] == 0} then {
unresolved $testname
+ set LDFLAGS "$saved_LDFLAGS"
return
}
@@ -67,3 +75,5 @@ if {! [ld_simple_link $ld tmpdir/weak "$flags -T $srcdir/$subdir/weak.t tmpdir/w
fail $testname
}
}
+
+set LDFLAGS "$saved_LDFLAGS"