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 5/6] ldgram.y: add ASCII
Date: Wed, 15 Feb 2023 12:40:51 +0100	[thread overview]
Message-ID: <20230215114052.28292-6-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/ldgram.y | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/ld/ldgram.y b/ld/ldgram.y
index 8240cf97327..6c3e510111c 100644
--- a/ld/ldgram.y
+++ b/ld/ldgram.y
@@ -91,7 +91,7 @@ static int error_index;
 }
 
 %type <etree> exp opt_exp_with_type mustbe_exp opt_at phdr_type phdr_val
-%type <etree> opt_exp_without_type opt_subalign opt_align
+%type <etree> mustbe_int opt_exp_without_type opt_subalign opt_align
 %type <fill> fill_opt fill_exp
 %type <name_list> exclude_name_list
 %type <wildcard_list> section_name_list
@@ -125,7 +125,7 @@ static int error_index;
 %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 ASCIII ASCIZ
 %token SECTIONS PHDRS INSERT_K AFTER BEFORE
 %token DATA_SEGMENT_ALIGN DATA_SEGMENT_RELRO_END DATA_SEGMENT_END
 %token SORT_BY_NAME SORT_BY_ALIGNMENT SORT_NONE
@@ -668,9 +668,21 @@ statement:
 		{
 		  lang_add_data ((int) $1, $3);
 		}
+	| ASCII '(' mustbe_int ')' NAME
+		{
+		  /* 'value' is a memory leak, do we care? */
+		  etree_type *value = $3;
+		  lang_add_string (value->value.value, $5);
+		}
+	| ASCII mustbe_int ',' NAME
+		{
+		  /* 'value' is a memory leak, do we care? */
+		  etree_type *value = $2;
+		  lang_add_string (value->value.value, $4);
+		}
 	| ASCIZ NAME
 		{
-		  lang_add_string ($2);
+		  lang_add_string (0, $2);
 		}
 	| FILL '(' fill_exp ')'
 		{
@@ -910,6 +922,15 @@ mustbe_exp:		{ ldlex_expression (); }
 			{ ldlex_popstate (); $$ = $2; }
 	;
 
+mustbe_int:		{ ldlex_expression (); }
+		INT
+			{ 
+			  etree_type *value = exp_bigintop ($2.integer, $2.str);
+			  ldlex_popstate ();
+			  $$ = value;
+			}
+	;
+
 exp	:
 		'-' exp %prec UNARY
 			{ $$ = exp_unop ('-', $2); }
-- 
2.17.1


  parent 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 ` [PATCH v0 1/6] Add testsuite for ASCII command binutils
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 ` binutils [this message]
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-6-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).