public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: binutils@emagii.com
To: binutils@sourceware.org
Cc: nickc@redhat.com, Ulf Samuelsson <ulf@emagii.com>
Subject: [PATCH v0 1/6] Add testsuite for ASCII command
Date: Wed, 15 Feb 2023 12:40:47 +0100	[thread overview]
Message-ID: <20230215114052.28292-2-binutils@emagii.com> (raw)
In-Reply-To: <20230215114052.28292-1-binutils@emagii.com>

From: Ulf Samuelsson <ulf@emagii.com>

Signed-off-by: Ulf Samuelsson <ulf@emagii.com>
---
 ld/testsuite/ld-scripts/ascii.d    | 155 +++++++++++++++++++++++++++++
 ld/testsuite/ld-scripts/ascii.s    |   9 ++
 ld/testsuite/ld-scripts/ascii.t    |  51 ++++++++++
 ld/testsuite/ld-scripts/header.inc |  34 +++++++
 4 files changed, 249 insertions(+)
 create mode 100644 ld/testsuite/ld-scripts/ascii.d
 create mode 100644 ld/testsuite/ld-scripts/ascii.s
 create mode 100644 ld/testsuite/ld-scripts/ascii.t
 create mode 100755 ld/testsuite/ld-scripts/header.inc

diff --git a/ld/testsuite/ld-scripts/ascii.d b/ld/testsuite/ld-scripts/ascii.d
new file mode 100644
index 00000000000..9c59896ff1d
--- /dev/null
+++ b/ld/testsuite/ld-scripts/ascii.d
@@ -0,0 +1,155 @@
+#source: ascii.s
+#ld: -T ascii.t
+#objdump: -s -j .text
+#notarget: [is_aout_format]
+#xfail: tic4x-*-* tic54x-*-*
+
+.*:     file format .*
+
+Contents of section .text:
+ 1100 434f4445 deadbeef 00000000 00000000  CODE............
+ 1110 00120000 f1080000 00000000 00000000  ................
+ 1120 01020304 17000000 00004711 deadbeef  ..........G.....
+ 1130 70726f67 72616d20 6e616d65 00000000  program name....
+ 1140 656d7074 79000000 00000000 00000000  empty...........
+ 1150 00000000 00000000 00000000 00000000  ................
+ 1160 00000000 00000000 00000000 00000000  ................
+ 1170 00000000 00000000 00000000 00000000  ................
+ 1180 636f6d6d 656e7420 315c6e00 00000000  comment 1\n.....
+ 1190 00000000 00000000 00000000 00000000  ................
+ 11a0 636f6d6d 656e7420 325c6e00 00000000  comment 2\n.....
+ 11b0 00000000 00000000 00000000 00000000  ................
+ 11c0 636f6d6d 656e7420 335c6e00 00000000  comment 3\n.....
+ 11d0 00000000 00000000 00000000 00000000  ................
+ 11e0 636f6d6d 656e7420 345c6e00 00000000  comment 4\n.....
+ 11f0 00000000 00000000 deadbeef 434f4445  ............CODE
+ 1200 434f4445 10110000 ffffffff ffffffff  CODE............
+ 1210 ffffffff ffffffff ffffffff ffffffff  ................
+ 1220 ffffffff ffffffff ffffffff ffffffff  ................
+ 1230 ffffffff ffffffff ffffffff ffffffff  ................
+ 1240 ffffffff ffffffff ffffffff ffffffff  ................
+ 1250 ffffffff ffffffff ffffffff ffffffff  ................
+ 1260 ffffffff ffffffff ffffffff ffffffff  ................
+ 1270 ffffffff ffffffff ffffffff ffffffff  ................
+ 1280 ffffffff ffffffff ffffffff ffffffff  ................
+ 1290 ffffffff ffffffff ffffffff ffffffff  ................
+ 12a0 ffffffff ffffffff ffffffff ffffffff  ................
+ 12b0 ffffffff ffffffff ffffffff ffffffff  ................
+ 12c0 ffffffff ffffffff ffffffff ffffffff  ................
+ 12d0 ffffffff ffffffff ffffffff ffffffff  ................
+ 12e0 ffffffff ffffffff ffffffff ffffffff  ................
+ 12f0 ffffffff ffffffff ffffffff ffffffff  ................
+ 1300 54686973 20697320 61207374 72696e67  This is a string
+ 1310 2c203132 38206279 7465206c 6f6e6700  , 128 byte long.
+ 1320 00000000 00000000 00000000 00000000  ................
+ 1330 00000000 00000000 00000000 00000000  ................
+ 1340 00000000 00000000 00000000 00000000  ................
+ 1350 00000000 00000000 00000000 00000000  ................
+ 1360 00000000 00000000 00000000 00000000  ................
+ 1370 00000000 00000000 00000000 00000000  ................
+ 1380 10110000 ffffffff ffffffff ffffffff  ................
+ 1390 54686973 20697320 616e2075 6e616c69  This is an unali
+ 13a0 676e6564 20737472 696e6700 01020304  gned string.....
+ 13b0 04070101 ffffffff ffffffff ffffffff  ................
+ 13c0 01ffffff ffffffff ffffffff ffffffff  ................
+ 13d0 54686973 20697300 ffffffff ffffffff  This is.........
+ 13e0 49206d65 616e7420 746f2073 61793a20  I meant to say: 
+ 13f0 54686973 20697320 77617920 746f6f20  This is way too 
+ 1400 6c6f6e67 00000000 00000000 00000000  long............
+ 1410 00000000 00000000 00000000 00000000  ................
+ 1420 ffffffff ffffffff ffffffff ffffffff  ................
+ 1430 ffffffff ffffffff ffffffff ffffffff  ................
+ 1440 ffffffff ffffffff ffffffff ffffffff  ................
+ 1450 ffffffff ffffffff ffffffff ffffffff  ................
+ 1460 ffffffff ffffffff ffffffff ffffffff  ................
+ 1470 ffffffff ffffffff ffffffff ffffffff  ................
+ 1480 ffffffff ffffffff ffffffff ffffffff  ................
+ 1490 ffffffff ffffffff ffffffff ffffffff  ................
+ 14a0 ffffffff ffffffff ffffffff ffffffff  ................
+ 14b0 ffffffff ffffffff ffffffff ffffffff  ................
+ 14c0 ffffffff ffffffff ffffffff ffffffff  ................
+ 14d0 ffffffff ffffffff ffffffff ffffffff  ................
+ 14e0 ffffffff ffffffff ffffffff ffffffff  ................
+ 14f0 ffffffff ffffffff ffffffff ffffffff  ................
+ 1500 ffffffff ffffffff ffffffff ffffffff  ................
+ 1510 ffffffff ffffffff ffffffff ffffffff  ................
+ 1520 ffffffff ffffffff ffffffff ffffffff  ................
+ 1530 ffffffff ffffffff ffffffff ffffffff  ................
+ 1540 ffffffff ffffffff ffffffff ffffffff  ................
+ 1550 ffffffff ffffffff ffffffff ffffffff  ................
+ 1560 ffffffff ffffffff ffffffff ffffffff  ................
+ 1570 ffffffff ffffffff ffffffff ffffffff  ................
+ 1580 ffffffff ffffffff ffffffff ffffffff  ................
+ 1590 ffffffff ffffffff ffffffff ffffffff  ................
+ 15a0 ffffffff ffffffff ffffffff ffffffff  ................
+ 15b0 ffffffff ffffffff ffffffff ffffffff  ................
+ 15c0 ffffffff ffffffff ffffffff ffffffff  ................
+ 15d0 ffffffff ffffffff ffffffff ffffffff  ................
+ 15e0 ffffffff ffffffff ffffffff ffffffff  ................
+ 15f0 ffffffff ffffffff ffffffff ffffffff  ................
+ 1600 ffffffff ffffffff ffffffff ffffffff  ................
+ 1610 ffffffff ffffffff ffffffff ffffffff  ................
+ 1620 ffffffff ffffffff ffffffff ffffffff  ................
+ 1630 ffffffff ffffffff ffffffff ffffffff  ................
+ 1640 ffffffff ffffffff ffffffff ffffffff  ................
+ 1650 ffffffff ffffffff ffffffff ffffffff  ................
+ 1660 ffffffff ffffffff ffffffff ffffffff  ................
+ 1670 ffffffff ffffffff ffffffff ffffffff  ................
+ 1680 ffffffff ffffffff ffffffff ffffffff  ................
+ 1690 ffffffff ffffffff ffffffff ffffffff  ................
+ 16a0 ffffffff ffffffff ffffffff ffffffff  ................
+ 16b0 ffffffff ffffffff ffffffff ffffffff  ................
+ 16c0 ffffffff ffffffff ffffffff ffffffff  ................
+ 16d0 ffffffff ffffffff ffffffff ffffffff  ................
+ 16e0 ffffffff ffffffff ffffffff ffffffff  ................
+ 16f0 ffffffff ffffffff ffffffff ffffffff  ................
+ 1700 ffffffff ffffffff ffffffff ffffffff  ................
+ 1710 ffffffff ffffffff ffffffff ffffffff  ................
+ 1720 ffffffff ffffffff ffffffff ffffffff  ................
+ 1730 ffffffff ffffffff ffffffff ffffffff  ................
+ 1740 ffffffff ffffffff ffffffff ffffffff  ................
+ 1750 ffffffff ffffffff ffffffff ffffffff  ................
+ 1760 ffffffff ffffffff ffffffff ffffffff  ................
+ 1770 ffffffff ffffffff ffffffff ffffffff  ................
+ 1780 ffffffff ffffffff ffffffff ffffffff  ................
+ 1790 ffffffff ffffffff ffffffff ffffffff  ................
+ 17a0 ffffffff ffffffff ffffffff ffffffff  ................
+ 17b0 ffffffff ffffffff ffffffff ffffffff  ................
+ 17c0 ffffffff ffffffff ffffffff ffffffff  ................
+ 17d0 ffffffff ffffffff ffffffff ffffffff  ................
+ 17e0 ffffffff ffffffff ffffffff ffffffff  ................
+ 17f0 ffffffff ffffffff ffffffff ffffffff  ................
+ 1800 41207665 7279206c 6f6e6720 73747269  A very long stri
+ 1810 6e672066 6f6c6c6f 77656420 62792061  ng followed by a
+ 1820 20273031 27000000 00000000 00000000   '01'...........
+ 1830 00000000 00000000 00000000 00000000  ................
+ 1840 00000000 00000000 00000000 00000000  ................
+ 1850 00000000 00000000 00000000 00000000  ................
+ 1860 00000000 00000000 00000000 00000000  ................
+ 1870 00000000 00000000 00000000 00000000  ................
+ 1880 00000000 00000000 00000000 00000000  ................
+ 1890 00000000 00000000 00000000 00000000  ................
+ 18a0 00000000 00000000 00000000 00000000  ................
+ 18b0 00000000 00000000 00000000 00000000  ................
+ 18c0 00000000 00000000 00000000 00000000  ................
+ 18d0 00000000 00000000 00000000 00000000  ................
+ 18e0 00000000 00000000 00000000 00000000  ................
+ 18f0 00000000 00000000 00000000 00000000  ................
+ 1900 00000000 00000000 00000000 00000000  ................
+ 1910 00000000 00000000 00000000 00000000  ................
+ 1920 00000000 00000000 00000000 00000000  ................
+ 1930 00000000 00000000 00000000 00000000  ................
+ 1940 00000000 00000000 00000000 00000000  ................
+ 1950 00000000 00000000 00000000 00000000  ................
+ 1960 00000000 00000000 00000000 00000000  ................
+ 1970 00000000 00000000 00000000 00000000  ................
+ 1980 00000000 00000000 00000000 00000000  ................
+ 1990 00000000 00000000 00000000 00000000  ................
+ 19a0 00000000 00000000 00000000 00000000  ................
+ 19b0 00000000 00000000 00000000 00000000  ................
+ 19c0 00000000 00000000 00000000 00000000  ................
+ 19d0 00000000 00000000 00000000 00000000  ................
+ 19e0 00000000 00000000 00000000 00000000  ................
+ 19f0 00000000 00000000 00000000 00000000  ................
+ 1a00 01                                   .               
+#pass
diff --git a/ld/testsuite/ld-scripts/ascii.s b/ld/testsuite/ld-scripts/ascii.s
new file mode 100644
index 00000000000..704b492ae61
--- /dev/null
+++ b/ld/testsuite/ld-scripts/ascii.s
@@ -0,0 +1,9 @@
+    .extern ecc_start
+	.section .text
+main:
+	.long 0x45444F43
+	.long ecc_start
+	.section .data
+	.long 0x9abcdef0
+	.section .bss
+	.long 0
diff --git a/ld/testsuite/ld-scripts/ascii.t b/ld/testsuite/ld-scripts/ascii.t
new file mode 100644
index 00000000000..14e01ca5c60
--- /dev/null
+++ b/ld/testsuite/ld-scripts/ascii.t
@@ -0,0 +1,51 @@
+MEMORY {
+  rom : ORIGIN = 0x000000, LENGTH = 0x400000
+  ram : ORIGIN = 0x400000, LENGTH = 0x10000
+}
+
+_start = 0x000000;
+SECTIONS
+{
+  . = 0x1000 + SIZEOF_HEADERS;
+  .text ALIGN (0x100) :
+
+    {
+      INCLUDE "header.inc"
+
+      FILL(0xFF)
+      entry = .;
+      *(.text)
+      . = ALIGN(0x100);
+      ASCII (128) "This is a string, 128 byte long"
+/*      ASCII 32,"This is a string" */
+      LONG(ecc_start)
+      . = ALIGN(16);
+      align_label = .;
+      ASCIZ "This is an unaligned string"
+      unalign_label = .;
+      BYTE(1)
+      BYTE(2)
+      BYTE(3)
+      BYTE(4)
+      BYTE(4)
+      BYTE(7)
+      BYTE(1)
+      BYTE(1)
+      . = ALIGN(16);
+      BYTE(1)
+      . = ALIGN(16);
+      ASCII (8) "This is way too long"
+      . = ALIGN(16);
+      ASCII (64) "I meant to say: This is way too long"
+      . = ALIGN(1024);
+      ASCII (512) "A very long string followed by a '01'"
+      BYTE(1)
+      ecc_end = .;
+    } > rom
+
+  .data : AT (0x400000) { *(.data) } >ram /* NO default AT>rom */
+  . = ALIGN(0x20);
+  .bss : { *(.bss) } >ram /* NO default AT>rom */
+  /DISCARD/ : { *(*) }
+}
+
diff --git a/ld/testsuite/ld-scripts/header.inc b/ld/testsuite/ld-scripts/header.inc
new file mode 100755
index 00000000000..8376d332226
--- /dev/null
+++ b/ld/testsuite/ld-scripts/header.inc
@@ -0,0 +1,34 @@
+      /* HEADER */
+      FILL(0xFF)
+      QUAD(0xEFBEADDE45444F43);
+      crc64 = .;
+      QUAD(0)
+      ecc_start = .;
+      /* Program Entry */
+      LONG(entry)
+
+      /* Program size */
+      LONG(ecc_end - ecc_start)
+
+      /* Time Stamp */
+      time_since_epoch = .;
+      QUAD(0)
+
+      /* 32 bytes here */
+      /* Version info */
+      BYTE(1)
+      BYTE(2)
+      BYTE(3)
+      BYTE(4)
+      LONG(0x17)
+      LONG(0x11470000)
+      LONG(0xEFBEADDE)
+      /* 48 bytes here */
+      ASCII (16) "program name"
+      /* 64 bytes here */
+      ASCII (64) "empty"
+      ASCII (32) "comment 1\n"
+      ASCII (32) "comment 2\n"
+      ASCII (32) "comment 3\n"
+      ASCII (24) "comment 4\n"
+      QUAD(0x45444F43EFBEADDE);
-- 
2.17.1


  reply	other threads:[~2023-02-15 11:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-15 11:40 [RFC v0 0/6] ASCII Command for output section binutils
2023-02-15 11:40 ` binutils [this message]
2023-02-15 11:40 ` [PATCH v0 2/6] Add ASCII command info to NEWS binutils
2023-02-15 11:40 ` [PATCH v0 3/6] Add ASCII to info file binutils
2023-02-15 11:40 ` [PATCH v0 4/6] ldlex.l: add ASCII binutils
2023-02-15 11:44   ` Ulf Samuelsson
2023-02-15 11:40 ` [PATCH v0 5/6] ldgram.y: " binutils
2023-02-15 11:40 ` [PATCH v0 6/6] ldlang.*: parse ASCII command binutils
2023-02-15 17:07 ` [RFC v0 0/6] ASCII Command for output section Nick Clifton
2023-02-15 17:55   ` Ulf Samuelsson
2023-02-15 17:28 ` Nick Clifton
2023-02-15 17:52   ` Ulf Samuelsson
2023-02-15 18:29   ` Ulf Samuelsson
2023-02-16 16:31     ` Nick Clifton

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=20230215114052.28292-2-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).