From: binutils@emagii.com
To: binutils@sourceware.org
Cc: nickc@redhat.com, Ulf Samuelsson <ulf@emagii.com>
Subject: [PATCH v1 6/7] SECTOR: add testsuite
Date: Fri, 10 Mar 2023 01:08:16 +0100 [thread overview]
Message-ID: <20230310000817.751962-7-binutils@emagii.com> (raw)
In-Reply-To: <20230310000817.751962-1-binutils@emagii.com>
From: Ulf Samuelsson <ulf@emagii.com>
Add three tests for the ALIGN_SECTOR command.
1. Normal case
2. ALIGN_SECTOR used without a BANK command
3. Adding "dummy" BANK command to shift addresses.
Signed-off-by: Ulf Samuelsson <ulf@emagii.com>
---
ld/testsuite/ld-scripts/align.exp | 3 +
ld/testsuite/ld-scripts/align_dummy_sector.d | 38 ++++++++++++
ld/testsuite/ld-scripts/align_dummy_sector.s | 4 ++
ld/testsuite/ld-scripts/align_dummy_sector.t | 61 ++++++++++++++++++++
ld/testsuite/ld-scripts/align_sector.d | 38 ++++++++++++
ld/testsuite/ld-scripts/align_sector.s | 4 ++
ld/testsuite/ld-scripts/align_sector.t | 61 ++++++++++++++++++++
ld/testsuite/ld-scripts/align_sector_fail.d | 8 +++
ld/testsuite/ld-scripts/align_sector_fail.s | 4 ++
ld/testsuite/ld-scripts/align_sector_fail.t | 38 ++++++++++++
10 files changed, 259 insertions(+)
create mode 100644 ld/testsuite/ld-scripts/align_dummy_sector.d
create mode 100644 ld/testsuite/ld-scripts/align_dummy_sector.s
create mode 100644 ld/testsuite/ld-scripts/align_dummy_sector.t
create mode 100644 ld/testsuite/ld-scripts/align_sector.d
create mode 100644 ld/testsuite/ld-scripts/align_sector.s
create mode 100644 ld/testsuite/ld-scripts/align_sector.t
create mode 100644 ld/testsuite/ld-scripts/align_sector_fail.d
create mode 100644 ld/testsuite/ld-scripts/align_sector_fail.s
create mode 100644 ld/testsuite/ld-scripts/align_sector_fail.t
diff --git a/ld/testsuite/ld-scripts/align.exp b/ld/testsuite/ld-scripts/align.exp
index 382a711b8cf..d9f39e42c68 100644
--- a/ld/testsuite/ld-scripts/align.exp
+++ b/ld/testsuite/ld-scripts/align.exp
@@ -46,6 +46,9 @@ if ![is_aout_format] {
run_dump_test align3
run_dump_test align4
run_dump_test align5
+ run_dump_test align_sector
+ run_dump_test align_dummy_sector
+ run_dump_test align_sector_fail
}
run_dump_test align2c
set LDFLAGS "$saved_LDFLAGS"
diff --git a/ld/testsuite/ld-scripts/align_dummy_sector.d b/ld/testsuite/ld-scripts/align_dummy_sector.d
new file mode 100644
index 00000000000..2198ef9b285
--- /dev/null
+++ b/ld/testsuite/ld-scripts/align_dummy_sector.d
@@ -0,0 +1,38 @@
+# source: align_dummy_sector.s
+# ld: -T align_dummy_sector.t
+# target: [is_elf_format] [is_coff_format]
+# notarget: [is_aout_format]
+# skip: tic4x-*-* tic54x-*-*
+# skip: ns32k-pc532-macho, pdp11-dec-aout, powerpc-ibm-aix5.2.0
+# skip: rs6000-aix4.3.3, alpha-linuxecoff
+# objdump: -s -j .text
+
+.*: file format .*
+
+Contents of section .text:
+ 10000 73656374 6f723000 00000000 ffffffff sector0.........
+ 10010 ffffffff ffffffff ffffffff ffffffff ................
+#...
+ 103f0 ffffffff ffffffff ffffffff ffffffff ................
+ 10400 73656374 6f723100 ffffffff ffffffff sector1.........
+ 10410 ffffffff ffffffff ffffffff ffffffff ................
+#...
+ 107f0 ffffffff ffffffff ffffffff ffffffff ................
+ 10800 73656374 6f723200 ffffffff ffffffff sector2.........
+ 10810 ffffffff ffffffff ffffffff ffffffff ................
+#...
+ 10bf0 ffffffff ffffffff ffffffff ffffffff ................
+ 10c00 73656374 6f723300 ffffffff ffffffff sector3.........
+ 10c10 ffffffff ffffffff ffffffff ffffffff ................
+#...
+ 10ff0 ffffffff ffffffff ffffffff ffffffff ................
+ 11000 73656374 6f723400 ffffffff ffffffff sector4.........
+ 11010 ffffffff ffffffff ffffffff ffffffff ................
+#...
+ 117f0 ffffffff ffffffff ffffffff ffffffff ................
+ 11800 73656374 6f723500 ffffffff ffffffff sector5.........
+ 11810 ffffffff ffffffff ffffffff ffffffff ................
+#...
+ 11ff0 ffffffff ffffffff ffffffff ffffffff ................
+ 12000 73656374 6f723600 ffffffff ffffffff sector6.........
+#pass
diff --git a/ld/testsuite/ld-scripts/align_dummy_sector.s b/ld/testsuite/ld-scripts/align_dummy_sector.s
new file mode 100644
index 00000000000..4e56d4a8e53
--- /dev/null
+++ b/ld/testsuite/ld-scripts/align_dummy_sector.s
@@ -0,0 +1,4 @@
+ .text
+ .long 0
+ .data
+ .long 0x12345678
diff --git a/ld/testsuite/ld-scripts/align_dummy_sector.t b/ld/testsuite/ld-scripts/align_dummy_sector.t
new file mode 100644
index 00000000000..e8d8eaecc94
--- /dev/null
+++ b/ld/testsuite/ld-scripts/align_dummy_sector.t
@@ -0,0 +1,61 @@
+MEMORY {
+ rom : ORIGIN = 0x10000, LENGTH = 0x4000
+ ram : ORIGIN = 0x14000, LENGTH = 0x1000
+}
+
+BANK ( dummy0 ) {
+ SECTOR ("64kB");
+}
+
+BANK ( bank0 ) {
+ SECTOR ("1 KB");
+ SECTOR ("1 KB");
+ SECTOR ("1 KB");
+ SECTOR ("1 KB");
+ SECTOR ("2 KB");
+ SECTOR ("2 KB");
+}
+
+SECTIONS
+{
+ .text : {
+ . = ALIGN(0x8000);
+ FILL(0xFF)
+ sector0 = .;
+ ASCIZ "sector0"
+ *(.text .pr)
+ ALIGN_SECTOR
+ sector1 = .;
+ ASCIZ "sector1"
+ ALIGN_SECTOR
+ sector2 = .;
+ ASCIZ "sector2"
+ ALIGN_SECTOR
+ sector3 = .;
+ ASCIZ "sector3"
+ ALIGN_SECTOR
+ sector4 = .;
+ ASCIZ "sector4"
+ ALIGN_SECTOR
+ sector5 = .;
+ ASCIZ "sector5"
+ ALIGN_SECTOR
+ sector6 = .;
+ ASCIZ "sector6"
+ . = ALIGN(0x10);
+ } > rom
+ .data : AT (0x400000) { *(.data) } >ram /* NO default AT>rom */
+ . = ALIGN(0x20);
+ .bss : { *(.bss) } >ram /* NO default AT>rom */
+
+ /*
+ ASSERT (sector0 == 0x0000, "Bad Address: sector0")
+ ASSERT (sector1 == 0x0400, "Bad Address: sector1")
+ ASSERT (sector2 == 0x0800, "Bad Address: sector2")
+ ASSERT (sector3 == 0x0C00, "Bad Address: sector3")
+ ASSERT (sector4 == 0x1000, "Bad Address: sector4")
+ ASSERT (sector5 == 0x1800, "Bad Address: sector5")
+ ASSERT (sector6 == 0x2000, "Bad Address: sector6")
+ */
+ /DISCARD/ : { *(*) }
+}
diff --git a/ld/testsuite/ld-scripts/align_sector.d b/ld/testsuite/ld-scripts/align_sector.d
new file mode 100644
index 00000000000..db95221ab2a
--- /dev/null
+++ b/ld/testsuite/ld-scripts/align_sector.d
@@ -0,0 +1,38 @@
+# source: align_sector.s
+# ld: -T align_sector.t
+# target: [is_elf_format] [is_coff_format]
+# notarget: [is_aout_format]
+# skip: tic4x-*-* tic54x-*-*
+# skip: ns32k-pc532-macho, pdp11-dec-aout, powerpc-ibm-aix5.2.0
+# skip: rs6000-aix4.3.3, alpha-linuxecoff
+# objdump: -s -j .text
+
+.*: file format .*
+
+Contents of section .text:
+ 0000 73656374 6f723000 00000000 ffffffff sector0.........
+ 0010 ffffffff ffffffff ffffffff ffffffff ................
+#...
+ 03f0 ffffffff ffffffff ffffffff ffffffff ................
+ 0400 73656374 6f723100 ffffffff ffffffff sector1.........
+ 0410 ffffffff ffffffff ffffffff ffffffff ................
+#...
+ 07f0 ffffffff ffffffff ffffffff ffffffff ................
+ 0800 73656374 6f723200 ffffffff ffffffff sector2.........
+ 0810 ffffffff ffffffff ffffffff ffffffff ................
+#...
+ 0bf0 ffffffff ffffffff ffffffff ffffffff ................
+ 0c00 73656374 6f723300 ffffffff ffffffff sector3.........
+ 0c10 ffffffff ffffffff ffffffff ffffffff ................
+#...
+ 0ff0 ffffffff ffffffff ffffffff ffffffff ................
+ 1000 73656374 6f723400 ffffffff ffffffff sector4.........
+ 1010 ffffffff ffffffff ffffffff ffffffff ................
+#...
+ 17f0 ffffffff ffffffff ffffffff ffffffff ................
+ 1800 73656374 6f723500 ffffffff ffffffff sector5.........
+ 1810 ffffffff ffffffff ffffffff ffffffff ................
+#...
+ 1ff0 ffffffff ffffffff ffffffff ffffffff ................
+ 2000 73656374 6f723600 ffffffff ffffffff sector6.........
+#pass
diff --git a/ld/testsuite/ld-scripts/align_sector.s b/ld/testsuite/ld-scripts/align_sector.s
new file mode 100644
index 00000000000..4e56d4a8e53
--- /dev/null
+++ b/ld/testsuite/ld-scripts/align_sector.s
@@ -0,0 +1,4 @@
+ .text
+ .long 0
+ .data
+ .long 0x12345678
diff --git a/ld/testsuite/ld-scripts/align_sector.t b/ld/testsuite/ld-scripts/align_sector.t
new file mode 100644
index 00000000000..83093e048da
--- /dev/null
+++ b/ld/testsuite/ld-scripts/align_sector.t
@@ -0,0 +1,61 @@
+MEMORY {
+ rom : ORIGIN = 0x0000, LENGTH = 0x4000
+ ram : ORIGIN = 0x4000, LENGTH = 0x1000
+}
+
+BANK ( dummy0 ) {
+ SECTOR ("32kB");
+}
+
+BANK ( bank0 ) {
+ SECTOR ("1 KB");
+ SECTOR ("1 KB");
+ SECTOR ("1 KB");
+ SECTOR ("1 KB");
+ SECTOR ("2 KB");
+ SECTOR ("2 KB");
+}
+
+SECTIONS
+{
+ .text : {
+ . = ALIGN(0x8000);
+ FILL(0xFF)
+ sector0 = .;
+ ASCIZ "sector0"
+ *(.text .pr)
+ ALIGN_SECTOR
+ sector1 = .;
+ ASCIZ "sector1"
+ ALIGN_SECTOR
+ sector2 = .;
+ ASCIZ "sector2"
+ ALIGN_SECTOR
+ sector3 = .;
+ ASCIZ "sector3"
+ ALIGN_SECTOR
+ sector4 = .;
+ ASCIZ "sector4"
+ ALIGN_SECTOR
+ sector5 = .;
+ ASCIZ "sector5"
+ ALIGN_SECTOR
+ sector6 = .;
+ ASCIZ "sector6"
+ . = ALIGN(0x10);
+ } > rom
+ .data : AT (0x400000) { *(.data) } >ram /* NO default AT>rom */
+ . = ALIGN(0x20);
+ .bss : { *(.bss) } >ram /* NO default AT>rom */
+
+ /*
+ ASSERT (sector0 == 0x0000, "Bad Address: sector0")
+ ASSERT (sector1 == 0x0400, "Bad Address: sector1")
+ ASSERT (sector2 == 0x0800, "Bad Address: sector2")
+ ASSERT (sector3 == 0x0C00, "Bad Address: sector3")
+ ASSERT (sector4 == 0x1000, "Bad Address: sector4")
+ ASSERT (sector5 == 0x1800, "Bad Address: sector5")
+ ASSERT (sector6 == 0x2000, "Bad Address: sector6")
+ */
+ /DISCARD/ : { *(*) }
+}
diff --git a/ld/testsuite/ld-scripts/align_sector_fail.d b/ld/testsuite/ld-scripts/align_sector_fail.d
new file mode 100644
index 00000000000..228009804a9
--- /dev/null
+++ b/ld/testsuite/ld-scripts/align_sector_fail.d
@@ -0,0 +1,8 @@
+# source: align_sector_fail.s
+# ld: -T align_sector_fail.t
+# error: .*: 'ALIGN_SECTOR' needs to be preceeded by a 'BANK' command.*
+# target: [is_elf_format] [is_coff_format]
+# notarget: [is_aout_format]
+# skip: tic4x-*-* tic54x-*-*
+# skip: ns32k-pc532-macho, pdp11-dec-aout, powerpc-ibm-aix5.2.0
+# skip: rs6000-aix4.3.3, alpha-linuxecoff
diff --git a/ld/testsuite/ld-scripts/align_sector_fail.s b/ld/testsuite/ld-scripts/align_sector_fail.s
new file mode 100644
index 00000000000..4e56d4a8e53
--- /dev/null
+++ b/ld/testsuite/ld-scripts/align_sector_fail.s
@@ -0,0 +1,4 @@
+ .text
+ .long 0
+ .data
+ .long 0x12345678
diff --git a/ld/testsuite/ld-scripts/align_sector_fail.t b/ld/testsuite/ld-scripts/align_sector_fail.t
new file mode 100644
index 00000000000..1e1dc231488
--- /dev/null
+++ b/ld/testsuite/ld-scripts/align_sector_fail.t
@@ -0,0 +1,38 @@
+MEMORY {
+ rom : ORIGIN = 0x0000, LENGTH = 0x4000
+ ram : ORIGIN = 0x4000, LENGTH = 0x1000
+}
+
+SECTIONS
+{
+ .text : {
+ FILL(0xFF)
+ sector0 = .;
+ ASCIZ "sector0"
+ *(.text .pr)
+ ALIGN_SECTOR
+ sector1 = .;
+ ASCIZ "sector1"
+ ALIGN_SECTOR
+ sector2 = .;
+ ASCIZ "sector2"
+ ALIGN_SECTOR
+ sector3 = .;
+ ASCIZ "sector3"
+ ALIGN_SECTOR
+ sector4 = .;
+ ASCIZ "sector4"
+ ALIGN_SECTOR
+ sector5 = .;
+ ASCIZ "sector5"
+ ALIGN_SECTOR
+ sector6 = .;
+ ASCIZ "sector6"
+ . = ALIGN(0x10);
+ } > rom
+ .data : AT (0x4000) { *(.data) } >ram /* NO default AT>rom */
+ . = ALIGN(0x20);
+ .bss : { *(.bss) } >ram /* NO default AT>rom */
+
+ /DISCARD/ : { *(*) }
+}
--
2.34.1
next prev parent reply other threads:[~2023-03-10 0:09 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-10 0:08 [PATCH v1 0/7 SECTOR: Support aligning to flash sector boundary binutils
2023-03-10 0:08 ` [PATCH v1 1/7] SECTOR: NEWS binutils
2023-03-10 0:08 ` [PATCH v1 2/7] SECTOR: ld.texi binutils
2023-03-10 0:08 ` [PATCH v1 3/7] SECTOR: ldlex.l binutils
2023-03-10 0:08 ` [PATCH v1 4/7] SECTOR: ldgram.y binutils
2023-03-10 0:08 ` [PATCH v1 5/7] SECTOR: language additions binutils
2023-03-10 0:08 ` binutils [this message]
2023-03-10 0:08 ` [PATCH v1 7/7] SECTOR: Makefile.* binutils
2023-03-10 3:46 ` [PATCH v1 0/7 SECTOR: Support aligning to flash sector boundary Alan Modra
2023-03-10 14:13 ` Michael Matz
2023-03-10 17:01 ` Ulf Samuelsson
2023-03-10 17:30 ` Michael Matz
2023-03-10 17:57 ` Ulf Samuelsson
2023-03-13 13:12 ` Michael Matz
2023-03-13 15:29 ` Ulf Samuelsson
2023-03-13 15:54 ` Michael Matz
2023-03-13 17:26 ` Ulf Samuelsson
2023-03-13 17:35 ` Michael Matz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230310000817.751962-7-binutils@emagii.com \
--to=binutils@emagii.com \
--cc=binutils@sourceware.org \
--cc=nickc@redhat.com \
--cc=ulf@emagii.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).