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 v5 06/10] DIGEST: ldgram.y
Date: Wed, 22 Feb 2023 17:16:05 +0100	[thread overview]
Message-ID: <20230222161609.239928-7-binutils@emagii.com> (raw)
In-Reply-To: <20230222161609.239928-1-binutils@emagii.com>

From: Ulf Samuelsson <ulf@emagii.com>

Parse the following commands

DIGEST "NAME"                 (start, end)
DIGEST POLY  (size, polynome) (start, end)
DIGEST POLYI (size, polynome) (start, end)
DIGEST TABLE
DIGEST SECTION "NAME"
TIMESTAMP
DEBUG ON
DEBUG OFF

Signed-off-by: Ulf Samuelsson <ulf@emagii.com>
---
 ld/ldgram.y | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)

diff --git a/ld/ldgram.y b/ld/ldgram.y
index faffeec94b8..2d752e52b6d 100644
--- a/ld/ldgram.y
+++ b/ld/ldgram.y
@@ -41,6 +41,7 @@
 #include "mri.h"
 #include "ldctor.h"
 #include "ldlex.h"
+#include "lddigest.h"
 
 #ifndef YYDEBUG
 #define YYDEBUG 1
@@ -130,6 +131,9 @@ static int error_index;
 %token DATA_SEGMENT_ALIGN DATA_SEGMENT_RELRO_END DATA_SEGMENT_END
 %token SORT_BY_NAME SORT_BY_ALIGNMENT SORT_NONE
 %token SORT_BY_INIT_PRIORITY
+%token DIGEST POLY POLYI TABLE SECTION
+%token TIMESTAMP
+%token DEBUG ON OFF
 %token '{' '}'
 %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
 %token INHIBIT_COMMON_ALLOCATION FORCE_GROUP_ALLOCATION
@@ -668,7 +672,7 @@ statement:
 		{
 		  lang_add_data ((int) $1, $3);
 		}
-        | ASCII '(' mustbe_exp ')' NAME
+	| ASCII '(' mustbe_exp ')' NAME
 		{
 		  /* 'value' is a memory leak, do we care?  */
 		  etree_type *value = $3;
@@ -682,6 +686,25 @@ statement:
 		{
 		  lang_add_fill ($3);
 		}
+	| DIGEST polynome '(' mustbe_exp ',' mustbe_exp ')'
+		{
+		  lang_add_assignment (exp_assign (CRC_ADDRESS, exp_nameop (NAME,"."), false));
+		  lang_add_assignment (exp_assign (CRC_START, $4, false));
+		  lang_add_assignment (exp_assign (CRC_END,   $6, false));
+		}
+	| DIGEST TABLE
+		{
+		  lang_add_assignment (exp_assign (CRC_TABLE, exp_nameop (NAME,"."), false));
+		  lang_add_digest_table ();
+		}
+	| DIGEST SECTION NAME
+		{
+		  lang_set_digest_section ($3);
+		}
+	| TIMESTAMP
+		{
+		  lang_add_timestamp ();
+		}
 	| ASSERT_K
 		{ ldlex_expression (); }
 	  '(' exp ',' NAME ')' separator
@@ -689,13 +712,36 @@ statement:
 		  ldlex_popstate ();
 		  lang_add_assignment (exp_assert ($4, $6));
 		}
+	| DEBUG ON
+		{
+		  yydebug = 1;
+		}
+	| DEBUG OFF
+		{
+		  yydebug = 0;
+		}
 	| INCLUDE filename
 		{
 		  ldfile_open_command_file ($2);
 		}
+
 	  statement_list_opt END
 	;
 
+polynome:
+	NAME
+		{
+		  lang_set_digest($1);
+		}
+	| POLY '(' mustbe_exp ',' mustbe_exp ')'
+		{
+		  lang_add_digest (false, $3->value.value, $5->value.value);
+		}
+	| POLYI '(' mustbe_exp ',' mustbe_exp ')'
+		{
+		  lang_add_digest (true,  $3->value.value, $5->value.value);
+		}
+
 statement_list:
 		statement_list statement
 	|	statement
-- 
2.34.1


  parent reply	other threads:[~2023-02-22 16:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-22 16:15 [PATCH v5 0/10 Add support for CRC64 generation in linker binutils
2023-02-22 16:16 ` [PATCH v5 01/10] TIMESTAMP: ldlang: process binutils
2023-02-22 16:16 ` [PATCH v5 02/10] DIGEST: NEWS binutils
2023-02-22 16:16 ` [PATCH v5 03/10] DIGEST: ld.texi binutils
2023-02-22 16:16 ` [PATCH v5 04/10] LIBCRC: license binutils
2023-02-22 16:16 ` [PATCH v5 05/10] DIGEST: ldlex.l binutils
2023-02-22 16:16 ` binutils [this message]
2023-02-22 16:16 ` [PATCH v5 07/10] DIGEST: Makefile.am: add new files binutils
2023-02-22 16:16 ` [PATCH v5 08/10] DIGEST: CRC-32/64 algorithms binutils
2023-02-22 16:16 ` [PATCH v5 09/10] DIGEST: ldmain.c: add CRC calculation binutils
2023-02-22 16:16 ` [PATCH v5 10/10] DIGEST: testsuite binutils
2023-02-22 18:23 ` [PATCH v5 0/10 Add support for CRC64 generation in linker Ulf Samuelsson

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=20230222161609.239928-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).