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 v2 2/7] ldgram.y: Add ASCII parsing
Date: Fri,  5 Jul 2024 18:22:43 +0200	[thread overview]
Message-ID: <20240705162248.24954-3-binutils@emagii.com> (raw)
In-Reply-To: <20240705162248.24954-1-binutils@emagii.com>

From: Ulf Samuelsson <ulf@emagii.com>

Signed-off-by: Ulf Samuelsson <ulf@emagii.com>
---
 ld/ldgram.y | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/ld/ldgram.y b/ld/ldgram.y
index 7c04025f526..1d6965ff49d 100644
--- a/ld/ldgram.y
+++ b/ld/ldgram.y
@@ -128,7 +128,7 @@ static void yyerror (const char *);
 %right UNARY
 %token END
 %left <token> '('
-%token <token> ALIGN_K BLOCK BIND QUAD SQUAD LONG SHORT BYTE ASCIZ
+%token <token> ALIGN_K BLOCK BIND QUAD SQUAD LONG SHORT BYTE ASCII ASCIZ
 %token SECTIONS PHDRS INSERT_K AFTER BEFORE LINKER_VERSION
 %token DATA_SEGMENT_ALIGN DATA_SEGMENT_RELRO_END DATA_SEGMENT_END
 %token SORT_BY_NAME SORT_BY_ALIGNMENT SORT_NONE
@@ -703,9 +703,18 @@ statement:
 		{
 		  lang_add_data ((int) $1, $3);
 		}
+        | ASCII mustbe_exp ',' NAME
+		{
+		  /* 'value' is a memory leak, do we care?  */
+		  etree_type *value = $2;
+		  if (value->type.node_code == INT)
+		    lang_add_string (value->value.value, $4);
+		  else
+		    einfo (_("%X%P:%pS: ASCII expression must be an integer\n"), NULL);
+		}
 	| ASCIZ NAME
 		{
-		  lang_add_string ($2);
+		  lang_add_string (0, $2);
 		}
 	| FILL '(' fill_exp ')'
 		{
-- 
2.17.1


  parent reply	other threads:[~2024-07-05 16:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-05 16:22 [PATCH v2 0/7] ASCII output section command binutils
2024-07-05 16:22 ` [PATCH v2 1/7] ldlex.l: Add ASCII token binutils
2024-07-05 16:22 ` binutils [this message]
2024-07-05 16:22 ` [PATCH v2 3/7] ldlang.*: process ASCII command binutils
2024-07-05 16:22 ` [PATCH v2 4/7] ld.texi: Add ASCII to info file binutils
2024-07-08  6:23   ` Jan Beulich
2024-07-08 10:59     ` Ulf Samuelsson
2024-07-05 16:22 ` [PATCH v2 5/7] Add testsuite for ASCII command binutils
2024-07-05 16:22 ` [PATCH v2 6/7] NEWS: Add " binutils
2024-07-05 16:22 ` [PATCH v2 7/7] ChangeLog: " binutils

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=20240705162248.24954-3-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).