summaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-scripts
diff options
context:
space:
mode:
authorH.J. Lu <hjl@lucon.org>2004-10-04 16:45:51 +0000
committerH.J. Lu <hjl@lucon.org>2004-10-04 16:45:51 +0000
commit1505566c51a951043bdadece96e28ea43c358601 (patch)
tree60d186863f715f2e176d5e0a2e00ee1dcd22cfbf /ld/testsuite/ld-scripts
parent1a4503dbf434a7fee87049cf284080c09ced790c (diff)
downloadbinutils-redhat-1505566c51a951043bdadece96e28ea43c358601.tar.gz
ld/
2004-10-04 H.J. Lu <hongjiu.lu@intel.com> * NEWS: Mention SORT_BY_NAME, SORT_BY_ALIGNMENT and --sort-section name|alignment. * ld.texinfo: Document SORT_BY_NAME, SORT_BY_ALIGNMENT and --sort-section name|alignment. * ld.h (sort_type): New enum. (wildcard_spec): Change the type of `sorted' to sort_type. * ldgram.y (SORT): Removed. (SORT_BY_NAME): Added. (SORT_BY_ALIGNMENT): Added. (wildcard_spec): Updated `sorted'. Handle SORT_BY_NAME and SORT_BY_ALIGNMENT. (input_section_spec_no_keep): Updated `sorted'. (statement): Replace SORT with SORT_BY_NAME. * ldlang.c (compare_section): New function to compare 2 sections with different sorting schemes. (wild_sort): Updated. Use compare_section. (update_wild_statements): New function. (lang_process): Call update_wild_statements before map_input_to_output_sections. * ldlex.l (SORT_BY_NAME): New. (SORT_BY_ALIGNMENT): New. (SORT): Return SORT_BY_NAME. * ldmain.c (sort_section): New. Defined. (main): Initialize it to none. * lexsup.c (option_values): Add OPTION_SORT_SECTION. (ld_options): Add an entry for OPTION_SORT_SECTION. (parse_args): Handle OPTION_SORT_SECTION. * mri.c (mri_draw_tree): Updated `sorted'. ld/testsuite/ 2004-10-04 H.J. Lu <hongjiu.lu@intel.com> * ld-scripts/sort.exp: New file for section sorting tests. * ld-scripts/sort_b_a.d: Likewise * ld-scripts/sort_b_a.s: Likewise * ld-scripts/sort_b_a.t: Likewise * ld-scripts/sort_b_a_a-1.d: Likewise * ld-scripts/sort_b_a_a-2.d: Likewise * ld-scripts/sort_b_a_a-3.d: Likewise * ld-scripts/sort_b_a_a.t: Likewise * ld-scripts/sort_b_a_n-1.d: Likewise * ld-scripts/sort_b_a_n-2.d: Likewise * ld-scripts/sort_b_a_n-3.d: Likewise * ld-scripts/sort_b_a_n.t: Likewise * ld-scripts/sort_b_n.d: Likewise * ld-scripts/sort_b_n.s: Likewise * ld-scripts/sort_b_n.t: Likewise * ld-scripts/sort_b_n_a-1.d: Likewise * ld-scripts/sort_b_n_a-2.d: Likewise * ld-scripts/sort_b_n_a-3.d: Likewise * ld-scripts/sort_b_n_a.t: Likewise * ld-scripts/sort_b_n_n-1.d: Likewise * ld-scripts/sort_b_n_n-2.d: Likewise * ld-scripts/sort_b_n_n-3.d: Likewise * ld-scripts/sort_b_n_n.t: Likewise * ld-scripts/sort_n_a-a.s: Likewise * ld-scripts/sort_n_a-b.s: Likewise * ld-scripts/sort_no-1.d: Likewise * ld-scripts/sort_no-2.d: Likewise * ld-scripts/sort_no.t: Likewise
Diffstat (limited to 'ld/testsuite/ld-scripts')
-rw-r--r--ld/testsuite/ld-scripts/sort.exp26
-rw-r--r--ld/testsuite/ld-scripts/sort_b_a.d9
-rw-r--r--ld/testsuite/ld-scripts/sort_b_a.s16
-rw-r--r--ld/testsuite/ld-scripts/sort_b_a.t5
-rw-r--r--ld/testsuite/ld-scripts/sort_b_a_a-1.d14
-rw-r--r--ld/testsuite/ld-scripts/sort_b_a_a-2.d14
-rw-r--r--ld/testsuite/ld-scripts/sort_b_a_a-3.d14
-rw-r--r--ld/testsuite/ld-scripts/sort_b_a_a.t5
-rw-r--r--ld/testsuite/ld-scripts/sort_b_a_n-1.d14
-rw-r--r--ld/testsuite/ld-scripts/sort_b_a_n-2.d14
-rw-r--r--ld/testsuite/ld-scripts/sort_b_a_n-3.d14
-rw-r--r--ld/testsuite/ld-scripts/sort_b_a_n.t5
-rw-r--r--ld/testsuite/ld-scripts/sort_b_n.d9
-rw-r--r--ld/testsuite/ld-scripts/sort_b_n.s12
-rw-r--r--ld/testsuite/ld-scripts/sort_b_n.t5
-rw-r--r--ld/testsuite/ld-scripts/sort_b_n_a-1.d14
-rw-r--r--ld/testsuite/ld-scripts/sort_b_n_a-2.d14
-rw-r--r--ld/testsuite/ld-scripts/sort_b_n_a-3.d14
-rw-r--r--ld/testsuite/ld-scripts/sort_b_n_a.t5
-rw-r--r--ld/testsuite/ld-scripts/sort_b_n_n-1.d14
-rw-r--r--ld/testsuite/ld-scripts/sort_b_n_n-2.d14
-rw-r--r--ld/testsuite/ld-scripts/sort_b_n_n-3.d14
-rw-r--r--ld/testsuite/ld-scripts/sort_b_n_n.t5
-rw-r--r--ld/testsuite/ld-scripts/sort_n_a-a.s16
-rw-r--r--ld/testsuite/ld-scripts/sort_n_a-b.s16
-rw-r--r--ld/testsuite/ld-scripts/sort_no-1.d9
-rw-r--r--ld/testsuite/ld-scripts/sort_no-2.d9
-rw-r--r--ld/testsuite/ld-scripts/sort_no.t5
28 files changed, 325 insertions, 0 deletions
diff --git a/ld/testsuite/ld-scripts/sort.exp b/ld/testsuite/ld-scripts/sort.exp
new file mode 100644
index 0000000000..af88223d64
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort.exp
@@ -0,0 +1,26 @@
+# Test SORT_BY_NAME/SORT_BY_ALIGNMENT/SORT in a linker script.
+# By H.J. Lu <hongjiu.lu@intel.com>
+# Copyright 2004
+# Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+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/ld/testsuite/ld-scripts/sort_b_a.d b/ld/testsuite/ld-scripts/sort_b_a.d
new file mode 100644
index 0000000000..78fe1f1015
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort_b_a.d
@@ -0,0 +1,9 @@
+#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
diff --git a/ld/testsuite/ld-scripts/sort_b_a.s b/ld/testsuite/ld-scripts/sort_b_a.s
new file mode 100644
index 0000000000..7b3851f80b
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/sort_b_a.t b/ld/testsuite/ld-scripts/sort_b_a.t
new file mode 100644
index 0000000000..cbfd3c3a9e
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort_b_a.t
@@ -0,0 +1,5 @@
+SECTIONS
+{
+ .text : {*(SORT_BY_ALIGNMENT(.text*))}
+ /DISCARD/ : { *(.*) }
+}
diff --git a/ld/testsuite/ld-scripts/sort_b_a_a-1.d b/ld/testsuite/ld-scripts/sort_b_a_a-1.d
new file mode 100644
index 0000000000..4f70646c12
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort_b_a_a-1.d
@@ -0,0 +1,14 @@
+#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
diff --git a/ld/testsuite/ld-scripts/sort_b_a_a-2.d b/ld/testsuite/ld-scripts/sort_b_a_a-2.d
new file mode 100644
index 0000000000..65919a448a
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort_b_a_a-2.d
@@ -0,0 +1,14 @@
+#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
diff --git a/ld/testsuite/ld-scripts/sort_b_a_a-3.d b/ld/testsuite/ld-scripts/sort_b_a_a-3.d
new file mode 100644
index 0000000000..21b7732cfc
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort_b_a_a-3.d
@@ -0,0 +1,14 @@
+#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
diff --git a/ld/testsuite/ld-scripts/sort_b_a_a.t b/ld/testsuite/ld-scripts/sort_b_a_a.t
new file mode 100644
index 0000000000..359cdffdd4
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/sort_b_a_n-1.d b/ld/testsuite/ld-scripts/sort_b_a_n-1.d
new file mode 100644
index 0000000000..62363bcf61
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort_b_a_n-1.d
@@ -0,0 +1,14 @@
+#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
diff --git a/ld/testsuite/ld-scripts/sort_b_a_n-2.d b/ld/testsuite/ld-scripts/sort_b_a_n-2.d
new file mode 100644
index 0000000000..7402836232
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort_b_a_n-2.d
@@ -0,0 +1,14 @@
+#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
diff --git a/ld/testsuite/ld-scripts/sort_b_a_n-3.d b/ld/testsuite/ld-scripts/sort_b_a_n-3.d
new file mode 100644
index 0000000000..4421c77f9f
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort_b_a_n-3.d
@@ -0,0 +1,14 @@
+#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
diff --git a/ld/testsuite/ld-scripts/sort_b_a_n.t b/ld/testsuite/ld-scripts/sort_b_a_n.t
new file mode 100644
index 0000000000..04c3917b4b
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/sort_b_n.d b/ld/testsuite/ld-scripts/sort_b_n.d
new file mode 100644
index 0000000000..531a756c4f
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort_b_n.d
@@ -0,0 +1,9 @@
+#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
diff --git a/ld/testsuite/ld-scripts/sort_b_n.s b/ld/testsuite/ld-scripts/sort_b_n.s
new file mode 100644
index 0000000000..c99d75c670
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/sort_b_n.t b/ld/testsuite/ld-scripts/sort_b_n.t
new file mode 100644
index 0000000000..26c2b6ea5d
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort_b_n.t
@@ -0,0 +1,5 @@
+SECTIONS
+{
+ .text : {*(SORT_BY_NAME(.text*))}
+ /DISCARD/ : { *(.*) }
+}
diff --git a/ld/testsuite/ld-scripts/sort_b_n_a-1.d b/ld/testsuite/ld-scripts/sort_b_n_a-1.d
new file mode 100644
index 0000000000..ee123bf676
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort_b_n_a-1.d
@@ -0,0 +1,14 @@
+#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
diff --git a/ld/testsuite/ld-scripts/sort_b_n_a-2.d b/ld/testsuite/ld-scripts/sort_b_n_a-2.d
new file mode 100644
index 0000000000..82f1805304
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort_b_n_a-2.d
@@ -0,0 +1,14 @@
+#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
diff --git a/ld/testsuite/ld-scripts/sort_b_n_a-3.d b/ld/testsuite/ld-scripts/sort_b_n_a-3.d
new file mode 100644
index 0000000000..5f3c863228
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort_b_n_a-3.d
@@ -0,0 +1,14 @@
+#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
diff --git a/ld/testsuite/ld-scripts/sort_b_n_a.t b/ld/testsuite/ld-scripts/sort_b_n_a.t
new file mode 100644
index 0000000000..49cbdd3604
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/sort_b_n_n-1.d b/ld/testsuite/ld-scripts/sort_b_n_n-1.d
new file mode 100644
index 0000000000..0bc18aefd3
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort_b_n_n-1.d
@@ -0,0 +1,14 @@
+#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
diff --git a/ld/testsuite/ld-scripts/sort_b_n_n-2.d b/ld/testsuite/ld-scripts/sort_b_n_n-2.d
new file mode 100644
index 0000000000..834bf90f7d
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort_b_n_n-2.d
@@ -0,0 +1,14 @@
+#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
diff --git a/ld/testsuite/ld-scripts/sort_b_n_n-3.d b/ld/testsuite/ld-scripts/sort_b_n_n-3.d
new file mode 100644
index 0000000000..7ba8a8b08c
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort_b_n_n-3.d
@@ -0,0 +1,14 @@
+#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
diff --git a/ld/testsuite/ld-scripts/sort_b_n_n.t b/ld/testsuite/ld-scripts/sort_b_n_n.t
new file mode 100644
index 0000000000..b4eabfe256
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/sort_n_a-a.s b/ld/testsuite/ld-scripts/sort_n_a-a.s
new file mode 100644
index 0000000000..77dfc35e99
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/sort_n_a-b.s b/ld/testsuite/ld-scripts/sort_n_a-b.s
new file mode 100644
index 0000000000..781ba4ec99
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/sort_no-1.d b/ld/testsuite/ld-scripts/sort_no-1.d
new file mode 100644
index 0000000000..aef786391b
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort_no-1.d
@@ -0,0 +1,9 @@
+#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
diff --git a/ld/testsuite/ld-scripts/sort_no-2.d b/ld/testsuite/ld-scripts/sort_no-2.d
new file mode 100644
index 0000000000..ddcd1c10e1
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort_no-2.d
@@ -0,0 +1,9 @@
+#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
diff --git a/ld/testsuite/ld-scripts/sort_no.t b/ld/testsuite/ld-scripts/sort_no.t
new file mode 100644
index 0000000000..d797c796e2
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sort_no.t
@@ -0,0 +1,5 @@
+SECTIONS
+{
+ .text : {*(.text*)}
+ /DISCARD/ : { *(.*) }
+}