From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from emagii.se (www.emagii.com [185.133.207.17]) by sourceware.org (Postfix) with ESMTPS id 4615F3850876 for ; Fri, 10 Mar 2023 00:09:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4615F3850876 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=emagii.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=emagii.com Received: from valinor.ownit.se (84-55-68-216.customers.ownit.se [84.55.68.216]) by emagii.se (Postfix) with ESMTPSA id 240AD12026B; Fri, 10 Mar 2023 01:09:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emagii.com; s=default; t=1678406950; bh=D219ri38JULbMXuunzhT45D2wFUEUGsqmKdI2RFYdKU=; h=From:To:Subject; b=yaIqVLHolvyU9weGyEHPplTvTK8FeyK+XSFC+uqWigKKzuaps14Z6sZJIv77qFOJt RihpqsXZo8oiDy4tp6FSexrrSTGIVwh+awlu9Vs6XYHdmAR5uXFiBCumq86f4X7q3w uTZDzahKAifUQa7kFN56agSg6wL/hduzNc3/Vb9Q= Authentication-Results: emagii.beebytevps.io; spf=pass (sender IP is 84.55.68.216) smtp.mailfrom=binutils@emagii.com smtp.helo=valinor.ownit.se Received-SPF: pass (emagii.beebytevps.io: connection is authenticated) From: binutils@emagii.com To: binutils@sourceware.org Cc: nickc@redhat.com, Ulf Samuelsson Subject: [PATCH v1 6/7] SECTOR: add testsuite Date: Fri, 10 Mar 2023 01:08:16 +0100 Message-Id: <20230310000817.751962-7-binutils@emagii.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230310000817.751962-1-binutils@emagii.com> References: <20230310000817.751962-1-binutils@emagii.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-PPP-Message-ID: <167840694880.3748167.5904101303137837049@localhost.localdomain> X-PPP-Vhost: emagii.com X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_FAIL,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Ulf Samuelsson 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 --- 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