aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2024-05-10 16:59:05 +0100
committerNick Clifton <nickc@redhat.com>2024-05-10 16:59:05 +0100
commit6e8376fa569e62379a42b91b0afd1f4086f1d897 (patch)
treed9bddaa0a8b3b242ba063df4dbbee272220ea385 /ld/testsuite
parentad658482c1e4feec4ac99c8e7df17ff78d0c2996 (diff)
downloadgdb-6e8376fa569e62379a42b91b0afd1f4086f1d897.zip
gdb-6e8376fa569e62379a42b91b0afd1f4086f1d897.tar.gz
gdb-6e8376fa569e62379a42b91b0afd1f4086f1d897.tar.bz2
Add --section-ordering command line option to the bfd linker.
Diffstat (limited to 'ld/testsuite')
-rw-r--r--ld/testsuite/ld-scripts/section-order-1a.d22
-rw-r--r--ld/testsuite/ld-scripts/section-order-1a.s29
-rw-r--r--ld/testsuite/ld-scripts/section-order-1a.t14
-rw-r--r--ld/testsuite/ld-scripts/section-order-1b.d18
-rw-r--r--ld/testsuite/ld-scripts/section-order-1b.s34
-rw-r--r--ld/testsuite/ld-scripts/section-order-1b.t7
-rw-r--r--ld/testsuite/ld-scripts/section-order-1c.d14
-rw-r--r--ld/testsuite/ld-scripts/section-order-1d.d18
-rw-r--r--ld/testsuite/ld-scripts/section-order.exp45
-rw-r--r--ld/testsuite/ld-scripts/start.s14
10 files changed, 215 insertions, 0 deletions
diff --git a/ld/testsuite/ld-scripts/section-order-1a.d b/ld/testsuite/ld-scripts/section-order-1a.d
new file mode 100644
index 0000000..40730b8
--- /dev/null
+++ b/ld/testsuite/ld-scripts/section-order-1a.d
@@ -0,0 +1,22 @@
+#name: Text Section Ordering (section-order-1a)
+#source: section-order-1b.s
+#source: section-order-1a.s
+#source: start.s
+#ld: --section-ordering-file section-order-1a.t
+#nm: -n
+
+#...
+[0-9a-f]+ T yyy
+#...
+[0-9a-f]+ T bar
+#...
+[0-9a-f]+ T [_]+start
+#...
+[0-9a-f]+ T xxx
+#...
+[0-9a-f]+ T foo
+#...
+[0-9a-f]+ T qqq
+#...
+[0-9a-f]+ T zzz
+#pass
diff --git a/ld/testsuite/ld-scripts/section-order-1a.s b/ld/testsuite/ld-scripts/section-order-1a.s
new file mode 100644
index 0000000..2394a7b
--- /dev/null
+++ b/ld/testsuite/ld-scripts/section-order-1a.s
@@ -0,0 +1,29 @@
+ .section .text.foo
+ .globl foo
+foo:
+ .dc.a 0
+
+ .section .text.bar
+ .globl bar
+bar:
+ .dc.a 0
+
+ .section .data.small
+ .globl small
+small:
+ .dc.a 0
+
+ .section .bar
+ .global bar
+bart:
+ .dc.a 0
+
+ .section .text.zzz
+ .global zzz
+zzz:
+ .dc.a 0
+
+ .section .data.bbb
+ .global bbb
+bbb:
+ .dc.a 0
diff --git a/ld/testsuite/ld-scripts/section-order-1a.t b/ld/testsuite/ld-scripts/section-order-1a.t
new file mode 100644
index 0000000..2e28bfa
--- /dev/null
+++ b/ld/testsuite/ld-scripts/section-order-1a.t
@@ -0,0 +1,14 @@
+.text : {
+ *(.text.yyy)
+ *(.text.b?r)
+ *(.text)
+ *(.text.xxx .text.foo)
+}
+
+.data : {
+ *(.data.small)
+ *(.big*)
+ *(.bar .baz*)
+ *(.data.ccc)
+}
+
diff --git a/ld/testsuite/ld-scripts/section-order-1b.d b/ld/testsuite/ld-scripts/section-order-1b.d
new file mode 100644
index 0000000..caf713d
--- /dev/null
+++ b/ld/testsuite/ld-scripts/section-order-1b.d
@@ -0,0 +1,18 @@
+#name: Text Section Ordering (section-order-1b)
+#source: section-order-1a.s
+#source: section-order-1b.s
+#source: start.s
+#ld: --section-ordering-file section-order-1b.t
+#nm: -n
+
+#...
+[0-9a-f]+ T yyy
+#...
+[0-9a-f]+ T bar
+#...
+[0-9a-f]+ T [_]+start
+#...
+[0-9a-f]+ T xxx
+#...
+[0-9a-f]+ T foo
+#pass
diff --git a/ld/testsuite/ld-scripts/section-order-1b.s b/ld/testsuite/ld-scripts/section-order-1b.s
new file mode 100644
index 0000000..49a0b32
--- /dev/null
+++ b/ld/testsuite/ld-scripts/section-order-1b.s
@@ -0,0 +1,34 @@
+ .section .text.xxx
+ .globl xxx
+xxx:
+ .dc.a 0
+
+ .section .text.yyy
+ .globl yyy
+yyy:
+ .dc.a 0
+
+ .section .big
+ .global big
+big:
+ .dc.a 0
+
+ .section .baz
+ .global baz
+baz:
+ .dc.a 0
+
+ .section .text.qqq
+ .global qqq
+qqq:
+ .dc.a 0
+
+ .section .data.ccc
+ .global ccc
+ccc:
+ .dc.a 0
+
+ .data
+ .global data_symbol
+data_symbol:
+ .dc.a 0
diff --git a/ld/testsuite/ld-scripts/section-order-1b.t b/ld/testsuite/ld-scripts/section-order-1b.t
new file mode 100644
index 0000000..6a36250
--- /dev/null
+++ b/ld/testsuite/ld-scripts/section-order-1b.t
@@ -0,0 +1,7 @@
+.text : {
+ *(.text.yyy)
+ *(.text.b?r)
+ *(*t)
+ *(.text.xxx)
+ *(.text.foo)
+}
diff --git a/ld/testsuite/ld-scripts/section-order-1c.d b/ld/testsuite/ld-scripts/section-order-1c.d
new file mode 100644
index 0000000..ad06d4a
--- /dev/null
+++ b/ld/testsuite/ld-scripts/section-order-1c.d
@@ -0,0 +1,14 @@
+#name: Data Section Ordering (section-order-1c)
+#source: section-order-1b.s
+#source: section-order-1a.s
+#source: start.s
+#ld: --section-ordering-file section-order-1a.t
+#nm: -n
+
+#...
+[0-9a-f]+ D small
+#...
+[0-9a-f]+ D big
+#...
+[0-9a-f]+ D ba.*
+#pass
diff --git a/ld/testsuite/ld-scripts/section-order-1d.d b/ld/testsuite/ld-scripts/section-order-1d.d
new file mode 100644
index 0000000..d016505
--- /dev/null
+++ b/ld/testsuite/ld-scripts/section-order-1d.d
@@ -0,0 +1,18 @@
+#name: Data Section Ordering (section-order-1d)
+#source: section-order-1a.s
+#source: section-order-1b.s
+#source: start.s
+#ld: --section-ordering-file section-order-1a.t
+#nm: -n
+
+#...
+[0-9a-f]+ D small
+#...
+[0-9a-f]+ D big
+#...
+[0-9a-f]+ d bart
+#...
+[0-9a-f]+ D ccc
+#...
+[0-9a-f]+ D bbb
+#pass
diff --git a/ld/testsuite/ld-scripts/section-order.exp b/ld/testsuite/ld-scripts/section-order.exp
new file mode 100644
index 0000000..9b87e74
--- /dev/null
+++ b/ld/testsuite/ld-scripts/section-order.exp
@@ -0,0 +1,45 @@
+# Test for --section-ordering-file FILE.
+# Copyright (C) 2024 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.
+
+# The --section-ordering-file option is only supported by ELF and
+# PE COFF linkers, which allow for arbitrarily named sections, eg:
+# .text.*
+if { !([is_elf_format] || [is_pecoff_format]) } {
+ return
+}
+
+set old_ldflags $LDFLAGS
+if { [istarget spu*-*-*] } then {
+ set LDFLAGS "$LDFLAGS --local-store 0:0 --no-overlays"
+} elseif { [is_pecoff_format] } then {
+ set LDFLAGS "$LDFLAGS --image-base 0"
+} elseif { [is_xcoff_format] } then {
+ set LDFLAGS "$LDFLAGS -bnogc"
+}
+
+set test_list [lsort [glob -nocomplain $srcdir/$subdir/section-order*.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/ld/testsuite/ld-scripts/start.s b/ld/testsuite/ld-scripts/start.s
new file mode 100644
index 0000000..3f64626
--- /dev/null
+++ b/ld/testsuite/ld-scripts/start.s
@@ -0,0 +1,14 @@
+ .text
+ .global start /* Used by SH targets. */
+start:
+ .global _start
+_start:
+ .global __start
+__start:
+ .global _mainCRTStartup /* Used by PE targets. */
+_mainCRTStartup:
+ .global main /* Used by HPPA targets. */
+main:
+ .globl _main /* Used by LynxOS targets. */
+_main:
+ .dc.a 0