summaryrefslogtreecommitdiffstats
path: root/binutils-2.21/ld/testsuite/ld-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'binutils-2.21/ld/testsuite/ld-scripts')
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/align.exp53
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/align.s2
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/align.t8
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/align2.t7
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/align2a.d12
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/align2a.s4
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/align2b.d12
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/align2b.s4
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/align2c.d2
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/align2c.s4
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/alignof.exp67
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/alignof.s9
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/alignof.t15
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/assert.exp34
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/assert.s1
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/assert.t10
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/cross1.c6
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/cross1.t10
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/cross2.c5
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/cross2.t6
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/cross3.c7
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/cross3.t10
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/cross4.c7
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/crossref.exp134
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/data.d9
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/data.exp30
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/data.s1
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/data.t11
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/default-script.exp34
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/default-script.s4
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/default-script.t7
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/default-script1.d9
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/default-script2.d9
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/default-script3.d9
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/default-script4.d9
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/defined.exp69
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/defined.s2
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/defined.t7
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/defined2.d22
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/defined2.t9
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/defined3.d35
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/defined3.t15
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/dynamic-sections-1.s2
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/dynamic-sections-2.s3
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/dynamic-sections.d6
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/dynamic-sections.exp27
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/dynamic-sections.t11
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-address-1.d9
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-address-1.s5
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-address-1.t11
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-address-2.s5
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-address-2a.d9
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-address-2a.t7
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-address-2b.d9
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-address-2b.t11
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-address-3.s5
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-address-3a.d9
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-address-3a.t10
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-address-3b.d9
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-address-3b.t11
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-address-3c.d10
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-address-3c.t11
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-address.exp32
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-aligned.d14
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-aligned.exp29
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-aligned.s2
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-aligned.t29
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-orphan.d6
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-orphan.exp37
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-orphan.s4
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/empty-orphan.t22
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/expr.exp23
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/expr1.d2
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/expr1.s2
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/expr1.t12
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/extern.exp71
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/extern.s1
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/extern.t14
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/include-1.d13
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/include-1.t4
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/include-data.t4
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/include-mem.t5
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/include-ram.t1
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/include-sections.t5
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/include-subdata.t2
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/include.exp40
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/include.s5
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/map-address.d12
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/map-address.exp47
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/map-address.t11
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/memory.t33
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/overlay-size-map.d29
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/overlay-size.d32
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/overlay-size.exp34
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/overlay-size.s25
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/overlay-size.t64
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/phdrs.exp68
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/phdrs.s8
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/phdrs.t16
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/phdrs2.exp74
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/phdrs2.s7
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/phdrs2.t23
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/phdrs3.d4
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/phdrs3.exp39
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/phdrs3.t16
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/phdrs3a.d9
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/phdrs3a.t15
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/provide-1.d9
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/provide-1.s4
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/provide-1.t12
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/provide-2.d7
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/provide-2.s8
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/provide-2.t10
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/provide-3.d3
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/provide-3.s4
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/provide-3.t11
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/provide.exp45
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/region-alias-1.t7
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/region-alias-2.t6
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/region-alias-3.t6
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/region-alias-4.t6
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-at.exp33
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-at.s6
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-at1.d15
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-at1.t13
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-at2.d15
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-at2.t14
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-at3.d15
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-at3.t13
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-at4.d16
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-at4.t14
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-at5.d20
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-at5.s14
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-at5.t26
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-over.exp54
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-over.s9
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-over1.d35
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-over1.t13
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-over2.d35
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-over2.t14
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-over3.d36
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-over3.t15
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-over4.d36
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-over4.t14
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-over5.d36
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-over5.t14
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-over6.d36
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-over6.t14
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-over7.d36
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-over7.t14
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-over8-ok.d15
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-over8.s7
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/rgn-over8.t13
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/script.exp138
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/script.s8
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/script.t16
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/scriptm.t10
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/section-match-1.d16
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/section-match-1.s5
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/section-match-1.t16
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/section-match.exp22
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/size-1.d14
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/size-1.s7
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/size-1.t10
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/size-2.d18
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/size-2.s8
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/size-2.t21
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/size.exp41
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sizeof.exp74
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sizeof.s1
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sizeof.t17
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort.exp40
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort.t5
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_a-1.d14
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_a-1.s16
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_a.d14
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_a.s16
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_a.t5
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_a_a-1.d23
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_a_a-2.d23
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_a_a-3.d23
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_a_a.t5
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_a_n-1.d23
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_a_n-2.d23
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_a_n-3.d23
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_a_n.t5
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_n-1.d14
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_n-1.s12
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_n.d14
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_n.s12
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_n.t5
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_n_a-1.d23
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_n_a-2.d23
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_n_a-3.d23
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_n_a.t5
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_n_n-1.d23
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_n_n-2.d23
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_n_n-3.d23
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_b_n_n.t5
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_n_a-a.s16
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_n_a-b.s16
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_no-1.d14
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_no-2.d14
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/sort_no.t5
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/weak.exp81
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/weak.t12
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/weak1.s11
-rw-r--r--binutils-2.21/ld/testsuite/ld-scripts/weak2.s11
208 files changed, 3728 insertions, 0 deletions
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/align.exp b/binutils-2.21/ld/testsuite/ld-scripts/align.exp
new file mode 100644
index 0000000..9ea46d0
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/align.s b/binutils-2.21/ld/testsuite/ld-scripts/align.s
new file mode 100644
index 0000000..c9bad23
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/align.s
@@ -0,0 +1,2 @@
+ .text
+ .long 0
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/align.t b/binutils-2.21/ld/testsuite/ld-scripts/align.t
new file mode 100644
index 0000000..49d6053
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/align2.t b/binutils-2.21/ld/testsuite/ld-scripts/align2.t
new file mode 100644
index 0000000..d86f62a
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/align2.t
@@ -0,0 +1,7 @@
+SECTIONS
+{
+ .text : {*(.text)}
+ . = ALIGN(data_align);
+ .data : {*(.data)}
+ /DISCARD/ : {*(*)}
+}
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/align2a.d b/binutils-2.21/ld/testsuite/ld-scripts/align2a.d
new file mode 100644
index 0000000..96237dd
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/align2a.s b/binutils-2.21/ld/testsuite/ld-scripts/align2a.s
new file mode 100644
index 0000000..4e56d4a
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/align2a.s
@@ -0,0 +1,4 @@
+ .text
+ .long 0
+ .data
+ .long 0x12345678
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/align2b.d b/binutils-2.21/ld/testsuite/ld-scripts/align2b.d
new file mode 100644
index 0000000..05d2a15
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/align2b.s b/binutils-2.21/ld/testsuite/ld-scripts/align2b.s
new file mode 100644
index 0000000..4e56d4a
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/align2b.s
@@ -0,0 +1,4 @@
+ .text
+ .long 0
+ .data
+ .long 0x12345678
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/align2c.d b/binutils-2.21/ld/testsuite/ld-scripts/align2c.d
new file mode 100644
index 0000000..16a4245
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/align2c.d
@@ -0,0 +1,2 @@
+# ld: -T align2.t
+# error: undefined symbol.*in expression
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/align2c.s b/binutils-2.21/ld/testsuite/ld-scripts/align2c.s
new file mode 100644
index 0000000..4e56d4a
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/align2c.s
@@ -0,0 +1,4 @@
+ .text
+ .long 0
+ .data
+ .long 0x12345678
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/alignof.exp b/binutils-2.21/ld/testsuite/ld-scripts/alignof.exp
new file mode 100644
index 0000000..0f05aeb
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/alignof.s b/binutils-2.21/ld/testsuite/ld-scripts/alignof.s
new file mode 100644
index 0000000..d440d2e
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/alignof.t b/binutils-2.21/ld/testsuite/ld-scripts/alignof.t
new file mode 100644
index 0000000..1241112
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/assert.exp b/binutils-2.21/ld/testsuite/ld-scripts/assert.exp
new file mode 100644
index 0000000..1de9001
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/assert.exp
@@ -0,0 +1,34 @@
+# 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
+}
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/assert.s b/binutils-2.21/ld/testsuite/ld-scripts/assert.s
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/assert.s
@@ -0,0 +1 @@
+
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/assert.t b/binutils-2.21/ld/testsuite/ld-scripts/assert.t
new file mode 100644
index 0000000..9b4c641
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/cross1.c b/binutils-2.21/ld/testsuite/ld-scripts/cross1.c
new file mode 100644
index 0000000..5678945
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/cross1.c
@@ -0,0 +1,6 @@
+extern int foo ();
+int
+func ()
+{
+ return foo ();
+}
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/cross1.t b/binutils-2.21/ld/testsuite/ld-scripts/cross1.t
new file mode 100644
index 0000000..c20e473
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/cross2.c b/binutils-2.21/ld/testsuite/ld-scripts/cross2.c
new file mode 100644
index 0000000..4143177
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/cross2.c
@@ -0,0 +1,5 @@
+int
+foo ()
+{
+ return 1;
+}
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/cross2.t b/binutils-2.21/ld/testsuite/ld-scripts/cross2.t
new file mode 100644
index 0000000..a0cdcbb
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/cross3.c b/binutils-2.21/ld/testsuite/ld-scripts/cross3.c
new file mode 100644
index 0000000..1848c32
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/cross3.c
@@ -0,0 +1,7 @@
+int i = 4;
+
+int
+foo ()
+{
+ return i;
+}
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/cross3.t b/binutils-2.21/ld/testsuite/ld-scripts/cross3.t
new file mode 100644
index 0000000..5e32bb2
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/cross4.c b/binutils-2.21/ld/testsuite/ld-scripts/cross4.c
new file mode 100644
index 0000000..aef8dfd
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/cross4.c
@@ -0,0 +1,7 @@
+__attribute__ ((section (".nocrossrefs")))
+static void
+foo ()
+{
+}
+
+void (*dummy) () = foo;
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/crossref.exp b/binutils-2.21/ld/testsuite/ld-scripts/crossref.exp
new file mode 100644
index 0000000..98178de
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/crossref.exp
@@ -0,0 +1,134 @@
+# 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
+}
+
+# Xtensa targets currently default to putting literal values in a separate
+# section and that requires linker script support, so put literals in text.
+global CFLAGS
+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"
+}
+
+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
+ 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
+ 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
+ return
+}
+
+if ![ld_relocate $ld tmpdir/cross3-partial.o "tmpdir/cross1.o tmpdir/cross4.o"] {
+ unresolved $test3
+ 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
+}
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/data.d b/binutils-2.21/ld/testsuite/ld-scripts/data.d
new file mode 100644
index 0000000..10b3d08
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/data.exp b/binutils-2.21/ld/testsuite/ld-scripts/data.exp
new file mode 100644
index 0000000..feb22aa
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/data.s b/binutils-2.21/ld/testsuite/ld-scripts/data.s
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/data.s
@@ -0,0 +1 @@
+
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/data.t b/binutils-2.21/ld/testsuite/ld-scripts/data.t
new file mode 100644
index 0000000..f56d10f
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/default-script.exp b/binutils-2.21/ld/testsuite/ld-scripts/default-script.exp
new file mode 100644
index 0000000..2e6fce0
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/default-script.s b/binutils-2.21/ld/testsuite/ld-scripts/default-script.s
new file mode 100644
index 0000000..78c474e
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/default-script.s
@@ -0,0 +1,4 @@
+ .text
+ .global text
+text:
+ .long 0
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/default-script.t b/binutils-2.21/ld/testsuite/ld-scripts/default-script.t
new file mode 100644
index 0000000..fc70187
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/default-script1.d b/binutils-2.21/ld/testsuite/ld-scripts/default-script1.d
new file mode 100644
index 0000000..61973f7
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/default-script2.d b/binutils-2.21/ld/testsuite/ld-scripts/default-script2.d
new file mode 100644
index 0000000..829718d
--- /dev/null
+++ b/binutils-2.21/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*8000000 T text
+#pass
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/default-script3.d b/binutils-2.21/ld/testsuite/ld-scripts/default-script3.d
new file mode 100644
index 0000000..b2da496
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/default-script4.d b/binutils-2.21/ld/testsuite/ld-scripts/default-script4.d
new file mode 100644
index 0000000..0010084
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/defined.exp b/binutils-2.21/ld/testsuite/ld-scripts/defined.exp
new file mode 100644
index 0000000..15cc079
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/defined.exp
@@ -0,0 +1,69 @@
+# Test DEFINED in a linker script.
+# By Ian Lance Taylor, Cygnus Support.
+# Copyright 2001, 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.
+
+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"
+set LDFLAGS "$saved_LDFLAGS"
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/defined.s b/binutils-2.21/ld/testsuite/ld-scripts/defined.s
new file mode 100644
index 0000000..243c397
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/defined.s
@@ -0,0 +1,2 @@
+ .globl defined
+ defined == 1
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/defined.t b/binutils-2.21/ld/testsuite/ld-scripts/defined.t
new file mode 100644
index 0000000..c1ef1b6
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/defined2.d b/binutils-2.21/ld/testsuite/ld-scripts/defined2.d
new file mode 100644
index 0000000..40728bd
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/defined2.t b/binutils-2.21/ld/testsuite/ld-scripts/defined2.t
new file mode 100644
index 0000000..50ddad0
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/defined3.d b/binutils-2.21/ld/testsuite/ld-scripts/defined3.d
new file mode 100644
index 0000000..61061b6
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/defined3.t b/binutils-2.21/ld/testsuite/ld-scripts/defined3.t
new file mode 100644
index 0000000..1fe6eef
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/dynamic-sections-1.s b/binutils-2.21/ld/testsuite/ld-scripts/dynamic-sections-1.s
new file mode 100644
index 0000000..9a72c96
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/dynamic-sections-1.s
@@ -0,0 +1,2 @@
+ .data
+ .4byte foo
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/dynamic-sections-2.s b/binutils-2.21/ld/testsuite/ld-scripts/dynamic-sections-2.s
new file mode 100644
index 0000000..57cb02d
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/dynamic-sections-2.s
@@ -0,0 +1,3 @@
+ .data
+ .global foo
+foo: .4byte 0
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/dynamic-sections.d b/binutils-2.21/ld/testsuite/ld-scripts/dynamic-sections.d
new file mode 100644
index 0000000..279107d
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/dynamic-sections.exp b/binutils-2.21/ld/testsuite/ld-scripts/dynamic-sections.exp
new file mode 100644
index 0000000..b1b3ae7
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/dynamic-sections.t b/binutils-2.21/ld/testsuite/ld-scripts/dynamic-sections.t
new file mode 100644
index 0000000..f1f24c8
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/empty-address-1.d b/binutils-2.21/ld/testsuite/ld-scripts/empty-address-1.d
new file mode 100644
index 0000000..29301ea
--- /dev/null
+++ b/binutils-2.21/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 A __data_end
+0+2000000 [ADT] __data_start
+#pass
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/empty-address-1.s b/binutils-2.21/ld/testsuite/ld-scripts/empty-address-1.s
new file mode 100644
index 0000000..c5cc1a5
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/empty-address-1.t b/binutils-2.21/ld/testsuite/ld-scripts/empty-address-1.t
new file mode 100644
index 0000000..57a8bed
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/empty-address-2.s b/binutils-2.21/ld/testsuite/ld-scripts/empty-address-2.s
new file mode 100644
index 0000000..79f58ea
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/empty-address-2a.d b/binutils-2.21/ld/testsuite/ld-scripts/empty-address-2a.d
new file mode 100644
index 0000000..689db61
--- /dev/null
+++ b/binutils-2.21/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 A __data_end
+#pass
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/empty-address-2a.t b/binutils-2.21/ld/testsuite/ld-scripts/empty-address-2a.t
new file mode 100644
index 0000000..6a40ad8
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/empty-address-2b.d b/binutils-2.21/ld/testsuite/ld-scripts/empty-address-2b.d
new file mode 100644
index 0000000..0c58946
--- /dev/null
+++ b/binutils-2.21/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 A __data_end
+#pass
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/empty-address-2b.t b/binutils-2.21/ld/testsuite/ld-scripts/empty-address-2b.t
new file mode 100644
index 0000000..dcf264f
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/empty-address-3.s b/binutils-2.21/ld/testsuite/ld-scripts/empty-address-3.s
new file mode 100644
index 0000000..6b07dd4
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/empty-address-3a.d b/binutils-2.21/ld/testsuite/ld-scripts/empty-address-3a.d
new file mode 100644
index 0000000..f475d41
--- /dev/null
+++ b/binutils-2.21/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 A __data_end
+#pass
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/empty-address-3a.t b/binutils-2.21/ld/testsuite/ld-scripts/empty-address-3a.t
new file mode 100644
index 0000000..2807e71
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/empty-address-3b.d b/binutils-2.21/ld/testsuite/ld-scripts/empty-address-3b.d
new file mode 100644
index 0000000..0a97fc2
--- /dev/null
+++ b/binutils-2.21/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 A __data_end
+#pass
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/empty-address-3b.t b/binutils-2.21/ld/testsuite/ld-scripts/empty-address-3b.t
new file mode 100644
index 0000000..4f213af
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/empty-address-3c.d b/binutils-2.21/ld/testsuite/ld-scripts/empty-address-3c.d
new file mode 100644
index 0000000..6001885
--- /dev/null
+++ b/binutils-2.21/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/binutils-2.21/ld/testsuite/ld-scripts/empty-address-3c.t b/binutils-2.21/ld/testsuite/ld-scripts/empty-address-3c.t
new file mode 100644
index 0000000..6de5198
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/empty-address.exp b/binutils-2.21/ld/testsuite/ld-scripts/empty-address.exp
new file mode 100644
index 0000000..6a2150f
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/empty-aligned.d b/binutils-2.21/ld/testsuite/ld-scripts/empty-aligned.d
new file mode 100644
index 0000000..283ef64
--- /dev/null
+++ b/binutils-2.21/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]+
+
+ Section to Segment mapping:
+ +Segment Sections\.\.\.
+ +00 +.text
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/empty-aligned.exp b/binutils-2.21/ld/testsuite/ld-scripts/empty-aligned.exp
new file mode 100644
index 0000000..70da61d
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/empty-aligned.s b/binutils-2.21/ld/testsuite/ld-scripts/empty-aligned.s
new file mode 100644
index 0000000..2079aa7
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/empty-aligned.s
@@ -0,0 +1,2 @@
+ .text
+ .long 123
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/empty-aligned.t b/binutils-2.21/ld/testsuite/ld-scripts/empty-aligned.t
new file mode 100644
index 0000000..e59bc20
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/empty-orphan.d b/binutils-2.21/ld/testsuite/ld-scripts/empty-orphan.d
new file mode 100644
index 0000000..7bd9b9a
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/empty-orphan.exp b/binutils-2.21/ld/testsuite/ld-scripts/empty-orphan.exp
new file mode 100644
index 0000000..0c6ebd7
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/empty-orphan.s b/binutils-2.21/ld/testsuite/ld-scripts/empty-orphan.s
new file mode 100644
index 0000000..c8fe675
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/empty-orphan.t b/binutils-2.21/ld/testsuite/ld-scripts/empty-orphan.t
new file mode 100644
index 0000000..b57e164
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/expr.exp b/binutils-2.21/ld/testsuite/ld-scripts/expr.exp
new file mode 100644
index 0000000..34829e5
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/expr.exp
@@ -0,0 +1,23 @@
+# Test ALIGN in a linker script.
+# By Nathan Sidwell, CodeSourcery LLC
+# Copyright 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.
+
+run_dump_test expr1
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/expr1.d b/binutils-2.21/ld/testsuite/ld-scripts/expr1.d
new file mode 100644
index 0000000..d96dfc1
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/expr1.d
@@ -0,0 +1,2 @@
+# ld: -T expr1.t
+# error: undefined section .* in expression
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/expr1.s b/binutils-2.21/ld/testsuite/ld-scripts/expr1.s
new file mode 100644
index 0000000..ec0ce90
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/expr1.s
@@ -0,0 +1,2 @@
+ .word 0
+
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/expr1.t b/binutils-2.21/ld/testsuite/ld-scripts/expr1.t
new file mode 100644
index 0000000..e0810ba
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/extern.exp b/binutils-2.21/ld/testsuite/ld-scripts/extern.exp
new file mode 100644
index 0000000..f05cd35
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/extern.s b/binutils-2.21/ld/testsuite/ld-scripts/extern.s
new file mode 100644
index 0000000..09cc1e1
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/extern.s
@@ -0,0 +1 @@
+ .text
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/extern.t b/binutils-2.21/ld/testsuite/ld-scripts/extern.t
new file mode 100644
index 0000000..b2a012a
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/include-1.d b/binutils-2.21/ld/testsuite/ld-scripts/include-1.d
new file mode 100644
index 0000000..4ad1fe8
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/include-1.t b/binutils-2.21/ld/testsuite/ld-scripts/include-1.t
new file mode 100644
index 0000000..cf2f8cd
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/include-data.t b/binutils-2.21/ld/testsuite/ld-scripts/include-data.t
new file mode 100644
index 0000000..eddbbb3
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/include-data.t
@@ -0,0 +1,4 @@
+.data : {
+INCLUDE include-subdata.t
+__end = .;
+}>ram
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/include-mem.t b/binutils-2.21/ld/testsuite/ld-scripts/include-mem.t
new file mode 100644
index 0000000..8aa65b1
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/include-ram.t b/binutils-2.21/ld/testsuite/ld-scripts/include-ram.t
new file mode 100644
index 0000000..f7eaf0e
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/include-ram.t
@@ -0,0 +1 @@
+ram (rw) : ORIGIN = 0x100000, LENGTH = 512
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/include-sections.t b/binutils-2.21/ld/testsuite/ld-scripts/include-sections.t
new file mode 100644
index 0000000..5d6ca1e
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/include-subdata.t b/binutils-2.21/ld/testsuite/ld-scripts/include-subdata.t
new file mode 100644
index 0000000..136c9f4
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/include-subdata.t
@@ -0,0 +1,2 @@
+ *(.data)
+
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/include.exp b/binutils-2.21/ld/testsuite/ld-scripts/include.exp
new file mode 100644
index 0000000..08fa1b6
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/include.s b/binutils-2.21/ld/testsuite/ld-scripts/include.s
new file mode 100644
index 0000000..e9fca05
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/map-address.d b/binutils-2.21/ld/testsuite/ld-scripts/map-address.d
new file mode 100644
index 0000000..7877ca4
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/map-address.exp b/binutils-2.21/ld/testsuite/ld-scripts/map-address.exp
new file mode 100644
index 0000000..499a824
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/map-address.t b/binutils-2.21/ld/testsuite/ld-scripts/map-address.t
new file mode 100644
index 0000000..e077ed1
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/memory.t b/binutils-2.21/ld/testsuite/ld-scripts/memory.t
new file mode 100644
index 0000000..129bd7c
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/overlay-size-map.d b/binutils-2.21/ld/testsuite/ld-scripts/overlay-size-map.d
new file mode 100644
index 0000000..a72d359
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/overlay-size.d b/binutils-2.21/ld/testsuite/ld-scripts/overlay-size.d
new file mode 100644
index 0000000..78a9c92
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/overlay-size.exp b/binutils-2.21/ld/testsuite/ld-scripts/overlay-size.exp
new file mode 100644
index 0000000..42c4348
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/overlay-size.s b/binutils-2.21/ld/testsuite/ld-scripts/overlay-size.s
new file mode 100644
index 0000000..5428c97
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/overlay-size.t b/binutils-2.21/ld/testsuite/ld-scripts/overlay-size.t
new file mode 100644
index 0000000..0d9af35
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/phdrs.exp b/binutils-2.21/ld/testsuite/ld-scripts/phdrs.exp
new file mode 100644
index 0000000..a112d3a
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/phdrs.exp
@@ -0,0 +1,68 @@
+# 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 tmpdir/phdrs"]
+ 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.21/ld/testsuite/ld-scripts/phdrs.s b/binutils-2.21/ld/testsuite/ld-scripts/phdrs.s
new file mode 100644
index 0000000..ec1f0d1
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/phdrs.s
@@ -0,0 +1,8 @@
+ .text
+
+ .long 1
+
+ .data
+
+ .long 2
+
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/phdrs.t b/binutils-2.21/ld/testsuite/ld-scripts/phdrs.t
new file mode 100644
index 0000000..283e30c
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/phdrs2.exp b/binutils-2.21/ld/testsuite/ld-scripts/phdrs2.exp
new file mode 100644
index 0000000..57778d2
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/phdrs2.exp
@@ -0,0 +1,74 @@
+# Test PHDRS with empty sections in a linker script.
+# Copyright 2006, 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.
+
+# PHDRS2 is only meaningful for ELF.
+if { ![istarget *-*-sysv4*] \
+ && ![istarget *-*-unixware*] \
+ && ![istarget *-*-elf*] \
+ && ![istarget *-*-eabi*] \
+ && ![istarget hppa*64*-*-hpux*] \
+ && ![istarget *-*-linux*] \
+ && ![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 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.21/ld/testsuite/ld-scripts/phdrs2.s b/binutils-2.21/ld/testsuite/ld-scripts/phdrs2.s
new file mode 100644
index 0000000..1e29ddc
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/phdrs2.t b/binutils-2.21/ld/testsuite/ld-scripts/phdrs2.t
new file mode 100644
index 0000000..bccbcec
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/phdrs3.d b/binutils-2.21/ld/testsuite/ld-scripts/phdrs3.d
new file mode 100644
index 0000000..7b37d80
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/phdrs3.exp b/binutils-2.21/ld/testsuite/ld-scripts/phdrs3.exp
new file mode 100644
index 0000000..9ab8363
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/phdrs3.t b/binutils-2.21/ld/testsuite/ld-scripts/phdrs3.t
new file mode 100644
index 0000000..4bd4e85
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/phdrs3a.d b/binutils-2.21/ld/testsuite/ld-scripts/phdrs3a.d
new file mode 100644
index 0000000..80bde71
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/phdrs3a.t b/binutils-2.21/ld/testsuite/ld-scripts/phdrs3a.t
new file mode 100644
index 0000000..c07ff34
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/provide-1.d b/binutils-2.21/ld/testsuite/ld-scripts/provide-1.d
new file mode 100644
index 0000000..ac8719a
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/provide-1.s b/binutils-2.21/ld/testsuite/ld-scripts/provide-1.s
new file mode 100644
index 0000000..1e33540
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/provide-1.s
@@ -0,0 +1,4 @@
+ .data
+ .globl foo
+foo: .long 0
+ .p2align 4
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/provide-1.t b/binutils-2.21/ld/testsuite/ld-scripts/provide-1.t
new file mode 100644
index 0000000..6b96b33
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/provide-2.d b/binutils-2.21/ld/testsuite/ld-scripts/provide-2.d
new file mode 100644
index 0000000..e151b30
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/provide-2.s b/binutils-2.21/ld/testsuite/ld-scripts/provide-2.s
new file mode 100644
index 0000000..f9138db
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/provide-2.t b/binutils-2.21/ld/testsuite/ld-scripts/provide-2.t
new file mode 100644
index 0000000..fe30dd8
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/provide-3.d b/binutils-2.21/ld/testsuite/ld-scripts/provide-3.d
new file mode 100644
index 0000000..c8b12da
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/provide-3.s b/binutils-2.21/ld/testsuite/ld-scripts/provide-3.s
new file mode 100644
index 0000000..1e33540
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/provide-3.s
@@ -0,0 +1,4 @@
+ .data
+ .globl foo
+foo: .long 0
+ .p2align 4
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/provide-3.t b/binutils-2.21/ld/testsuite/ld-scripts/provide-3.t
new file mode 100644
index 0000000..f6229d4
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/provide.exp b/binutils-2.21/ld/testsuite/ld-scripts/provide.exp
new file mode 100644
index 0000000..6db399f
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/region-alias-1.t b/binutils-2.21/ld/testsuite/ld-scripts/region-alias-1.t
new file mode 100644
index 0000000..91f8100
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/region-alias-2.t b/binutils-2.21/ld/testsuite/ld-scripts/region-alias-2.t
new file mode 100644
index 0000000..a6b1514
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/region-alias-3.t b/binutils-2.21/ld/testsuite/ld-scripts/region-alias-3.t
new file mode 100644
index 0000000..667879b
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/region-alias-4.t b/binutils-2.21/ld/testsuite/ld-scripts/region-alias-4.t
new file mode 100644
index 0000000..da9dff5
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-at.exp b/binutils-2.21/ld/testsuite/ld-scripts/rgn-at.exp
new file mode 100644
index 0000000..9095273
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-at.s b/binutils-2.21/ld/testsuite/ld-scripts/rgn-at.s
new file mode 100644
index 0000000..0628046
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-at1.d b/binutils-2.21/ld/testsuite/ld-scripts/rgn-at1.d
new file mode 100644
index 0000000..f301bbb
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-at1.t b/binutils-2.21/ld/testsuite/ld-scripts/rgn-at1.t
new file mode 100644
index 0000000..610be2a
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-at2.d b/binutils-2.21/ld/testsuite/ld-scripts/rgn-at2.d
new file mode 100644
index 0000000..8fd5f1a
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-at2.t b/binutils-2.21/ld/testsuite/ld-scripts/rgn-at2.t
new file mode 100644
index 0000000..57fd88c
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-at3.d b/binutils-2.21/ld/testsuite/ld-scripts/rgn-at3.d
new file mode 100644
index 0000000..1d21956
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/rgn-at3.d
@@ -0,0 +1,15 @@
+# name: rgn-at3
+# source: rgn-at.s
+# ld: -T rgn-at3.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+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.21/ld/testsuite/ld-scripts/rgn-at3.t b/binutils-2.21/ld/testsuite/ld-scripts/rgn-at3.t
new file mode 100644
index 0000000..4622e7e
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-at4.d b/binutils-2.21/ld/testsuite/ld-scripts/rgn-at4.d
new file mode 100644
index 0000000..9837343
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-at4.t b/binutils-2.21/ld/testsuite/ld-scripts/rgn-at4.t
new file mode 100644
index 0000000..0e3fec4
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-at5.d b/binutils-2.21/ld/testsuite/ld-scripts/rgn-at5.d
new file mode 100644
index 0000000..972c6c2
--- /dev/null
+++ b/binutils-2.21/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*
+# 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.21/ld/testsuite/ld-scripts/rgn-at5.s b/binutils-2.21/ld/testsuite/ld-scripts/rgn-at5.s
new file mode 100644
index 0000000..ce8576c
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-at5.t b/binutils-2.21/ld/testsuite/ld-scripts/rgn-at5.t
new file mode 100644
index 0000000..3a35994
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-over.exp b/binutils-2.21/ld/testsuite/ld-scripts/rgn-over.exp
new file mode 100644
index 0000000..8192487
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-over.s b/binutils-2.21/ld/testsuite/ld-scripts/rgn-over.s
new file mode 100644
index 0000000..f651cce
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-over1.d b/binutils-2.21/ld/testsuite/ld-scripts/rgn-over1.d
new file mode 100644
index 0000000..54892be
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-over1.t b/binutils-2.21/ld/testsuite/ld-scripts/rgn-over1.t
new file mode 100644
index 0000000..9c14f70
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-over2.d b/binutils-2.21/ld/testsuite/ld-scripts/rgn-over2.d
new file mode 100644
index 0000000..1a5afea
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-over2.t b/binutils-2.21/ld/testsuite/ld-scripts/rgn-over2.t
new file mode 100644
index 0000000..b38a9c1
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-over3.d b/binutils-2.21/ld/testsuite/ld-scripts/rgn-over3.d
new file mode 100644
index 0000000..76fa7c5
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-over3.t b/binutils-2.21/ld/testsuite/ld-scripts/rgn-over3.t
new file mode 100644
index 0000000..5341fb5
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-over4.d b/binutils-2.21/ld/testsuite/ld-scripts/rgn-over4.d
new file mode 100644
index 0000000..1087aec
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-over4.t b/binutils-2.21/ld/testsuite/ld-scripts/rgn-over4.t
new file mode 100644
index 0000000..d2463e9
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-over5.d b/binutils-2.21/ld/testsuite/ld-scripts/rgn-over5.d
new file mode 100644
index 0000000..734d9fe
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-over5.t b/binutils-2.21/ld/testsuite/ld-scripts/rgn-over5.t
new file mode 100644
index 0000000..2b0ae68
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-over6.d b/binutils-2.21/ld/testsuite/ld-scripts/rgn-over6.d
new file mode 100644
index 0000000..00b41d0
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-over6.t b/binutils-2.21/ld/testsuite/ld-scripts/rgn-over6.t
new file mode 100644
index 0000000..b78d184
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-over7.d b/binutils-2.21/ld/testsuite/ld-scripts/rgn-over7.d
new file mode 100644
index 0000000..50bd6af
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-over7.t b/binutils-2.21/ld/testsuite/ld-scripts/rgn-over7.t
new file mode 100644
index 0000000..4288e84
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-over8-ok.d b/binutils-2.21/ld/testsuite/ld-scripts/rgn-over8-ok.d
new file mode 100644
index 0000000..300e947
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/rgn-over8-ok.d
@@ -0,0 +1,15 @@
+# name: rgn-over8
+# source: rgn-over8.s
+# ld: -T rgn-over8.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+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.21/ld/testsuite/ld-scripts/rgn-over8.s b/binutils-2.21/ld/testsuite/ld-scripts/rgn-over8.s
new file mode 100644
index 0000000..0077a4f
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/rgn-over8.t b/binutils-2.21/ld/testsuite/ld-scripts/rgn-over8.t
new file mode 100644
index 0000000..7623b19
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/script.exp b/binutils-2.21/ld/testsuite/ld-scripts/script.exp
new file mode 100644
index 0000000..2e69922
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/script.exp
@@ -0,0 +1,138 @@
+# Test basic linker script functionality
+# By Ian Lance Taylor, Cygnus Support
+# Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2009, 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 "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 {
+ if ![ld_simple_link $ld tmpdir/script "$flags -T $test_script tmpdir/script.o"] {
+ xfail "REGION_ALIAS: $test_script"
+ } else {
+ xpass "REGION_ALIAS: $test_script"
+ }
+}
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/script.s b/binutils-2.21/ld/testsuite/ld-scripts/script.s
new file mode 100644
index 0000000..d7b65b0
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/script.t b/binutils-2.21/ld/testsuite/ld-scripts/script.t
new file mode 100644
index 0000000..ee7a48a
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/scriptm.t b/binutils-2.21/ld/testsuite/ld-scripts/scriptm.t
new file mode 100644
index 0000000..57ccae1
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/section-match-1.d b/binutils-2.21/ld/testsuite/ld-scripts/section-match-1.d
new file mode 100644
index 0000000..c68dbb8
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/section-match-1.s b/binutils-2.21/ld/testsuite/ld-scripts/section-match-1.s
new file mode 100644
index 0000000..3e32a88
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/section-match-1.t b/binutils-2.21/ld/testsuite/ld-scripts/section-match-1.t
new file mode 100644
index 0000000..155b3dc
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/section-match.exp b/binutils-2.21/ld/testsuite/ld-scripts/section-match.exp
new file mode 100644
index 0000000..bdca8cf
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/size-1.d b/binutils-2.21/ld/testsuite/ld-scripts/size-1.d
new file mode 100644
index 0000000..641fbca
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/size-1.s b/binutils-2.21/ld/testsuite/ld-scripts/size-1.s
new file mode 100644
index 0000000..7f5a5fd
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/size-1.t b/binutils-2.21/ld/testsuite/ld-scripts/size-1.t
new file mode 100644
index 0000000..bb48665
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/size-2.d b/binutils-2.21/ld/testsuite/ld-scripts/size-2.d
new file mode 100644
index 0000000..beb18e4
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/size-2.s b/binutils-2.21/ld/testsuite/ld-scripts/size-2.s
new file mode 100644
index 0000000..6b10250
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/size-2.t b/binutils-2.21/ld/testsuite/ld-scripts/size-2.t
new file mode 100644
index 0000000..e67b3fa
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/size.exp b/binutils-2.21/ld/testsuite/ld-scripts/size.exp
new file mode 100644
index 0000000..1d59158
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sizeof.exp b/binutils-2.21/ld/testsuite/ld-scripts/sizeof.exp
new file mode 100644
index 0000000..ed5d191
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sizeof.s b/binutils-2.21/ld/testsuite/ld-scripts/sizeof.s
new file mode 100644
index 0000000..e221ca3
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/sizeof.s
@@ -0,0 +1 @@
+ .space 16
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/sizeof.t b/binutils-2.21/ld/testsuite/ld-scripts/sizeof.t
new file mode 100644
index 0000000..6244a37
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort.exp b/binutils-2.21/ld/testsuite/ld-scripts/sort.exp
new file mode 100644
index 0000000..47950a7
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort.t b/binutils-2.21/ld/testsuite/ld-scripts/sort.t
new file mode 100644
index 0000000..c53481f
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/sort.t
@@ -0,0 +1,5 @@
+SECTIONS
+{
+ .text : {*(.text .text.*)}
+ /DISCARD/ : { *(.*) }
+}
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/sort_b_a-1.d b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_a-1.d
new file mode 100644
index 0000000..325193c
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_a-1.s b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_a-1.s
new file mode 100644
index 0000000..87d3613
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_a.d b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_a.d
new file mode 100644
index 0000000..0f55808
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_a.s b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_a.s
new file mode 100644
index 0000000..7b3851f
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_a.t b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_a.t
new file mode 100644
index 0000000..cbfd3c3
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_a.t
@@ -0,0 +1,5 @@
+SECTIONS
+{
+ .text : {*(SORT_BY_ALIGNMENT(.text*))}
+ /DISCARD/ : { *(.*) }
+}
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/sort_b_a_a-1.d b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_a_a-1.d
new file mode 100644
index 0000000..930f748
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_a_a-2.d b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_a_a-2.d
new file mode 100644
index 0000000..3e7d158
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_a_a-3.d b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_a_a-3.d
new file mode 100644
index 0000000..b1b0600
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_a_a.t b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_a_a.t
new file mode 100644
index 0000000..359cdff
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_a_n-1.d b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_a_n-1.d
new file mode 100644
index 0000000..dd5c613
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_a_n-2.d b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_a_n-2.d
new file mode 100644
index 0000000..f87ddd5
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_a_n-3.d b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_a_n-3.d
new file mode 100644
index 0000000..bf7ee4e
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_a_n.t b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_a_n.t
new file mode 100644
index 0000000..04c3917
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_n-1.d b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_n-1.d
new file mode 100644
index 0000000..76d60b6
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_n-1.s b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_n-1.s
new file mode 100644
index 0000000..5a49170
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_n.d b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_n.d
new file mode 100644
index 0000000..5ef07b2
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_n.s b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_n.s
new file mode 100644
index 0000000..c99d75c
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_n.t b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_n.t
new file mode 100644
index 0000000..26c2b6e
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_n.t
@@ -0,0 +1,5 @@
+SECTIONS
+{
+ .text : {*(SORT_BY_NAME(.text*))}
+ /DISCARD/ : { *(.*) }
+}
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/sort_b_n_a-1.d b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_n_a-1.d
new file mode 100644
index 0000000..22d6848
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_n_a-2.d b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_n_a-2.d
new file mode 100644
index 0000000..4c9d8fe
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_n_a-3.d b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_n_a-3.d
new file mode 100644
index 0000000..6657046
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_n_a.t b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_n_a.t
new file mode 100644
index 0000000..49cbdd3
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_n_n-1.d b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_n_n-1.d
new file mode 100644
index 0000000..b2b2dbe
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_n_n-2.d b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_n_n-2.d
new file mode 100644
index 0000000..15b66e4
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_n_n-3.d b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_n_n-3.d
new file mode 100644
index 0000000..b99f7e1
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_b_n_n.t b/binutils-2.21/ld/testsuite/ld-scripts/sort_b_n_n.t
new file mode 100644
index 0000000..b4eabfe
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_n_a-a.s b/binutils-2.21/ld/testsuite/ld-scripts/sort_n_a-a.s
new file mode 100644
index 0000000..77dfc35
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_n_a-b.s b/binutils-2.21/ld/testsuite/ld-scripts/sort_n_a-b.s
new file mode 100644
index 0000000..781ba4e
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_no-1.d b/binutils-2.21/ld/testsuite/ld-scripts/sort_no-1.d
new file mode 100644
index 0000000..c5f5593
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_no-2.d b/binutils-2.21/ld/testsuite/ld-scripts/sort_no-2.d
new file mode 100644
index 0000000..e0943d5
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/sort_no.t b/binutils-2.21/ld/testsuite/ld-scripts/sort_no.t
new file mode 100644
index 0000000..d797c79
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/sort_no.t
@@ -0,0 +1,5 @@
+SECTIONS
+{
+ .text : {*(.text*)}
+ /DISCARD/ : { *(.*) }
+}
diff --git a/binutils-2.21/ld/testsuite/ld-scripts/weak.exp b/binutils-2.21/ld/testsuite/ld-scripts/weak.exp
new file mode 100644
index 0000000..d021df7
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-scripts/weak.exp
@@ -0,0 +1,81 @@
+# Test weak symbols.
+# By Ian Lance Taylor, Cygnus Solutions.
+# Copyright 1999, 2000, 2002, 2004, 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.
+
+set testname "weak symbols"
+
+# This test only works for ELF 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 non-i386 PE targets.
+if {! [istarget i?86-*-*]} {
+ setup_xfail *-*-pe*
+ setup_xfail x86_64-*-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.21/ld/testsuite/ld-scripts/weak.t b/binutils-2.21/ld/testsuite/ld-scripts/weak.t
new file mode 100644
index 0000000..6cd013e
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/weak1.s b/binutils-2.21/ld/testsuite/ld-scripts/weak1.s
new file mode 100644
index 0000000..26bffbd
--- /dev/null
+++ b/binutils-2.21/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.21/ld/testsuite/ld-scripts/weak2.s b/binutils-2.21/ld/testsuite/ld-scripts/weak2.s
new file mode 100644
index 0000000..963b229
--- /dev/null
+++ b/binutils-2.21/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