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 <binutils@emagii.com>
Subject: [PATCH v4 4/5] ldgram.y: CRC64
Date: Sun, 19 Feb 2023 20:45:48 +0100	[thread overview]
Message-ID: <20230219194549.22554-5-binutils@emagii.com> (raw)
In-Reply-To: <20230219194549.22554-1-binutils@emagii.com>

From: Ulf Samuelsson <binutils@emagii.com>

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

diff --git a/ld/ldgram.y b/ld/ldgram.y
index faffeec94b8..1290518454d 100644
--- a/ld/ldgram.y
+++ b/ld/ldgram.y
@@ -41,6 +41,7 @@
 #include "mri.h"
 #include "ldctor.h"
 #include "ldlex.h"
+#include "checksum.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 CRC64 CRC32 ECMA ISO POLY POLYI TABLE
+%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,38 @@ statement:
 		{
 		  lang_add_fill ($3);
 		}
+	| CRC32
+		{
+		  lang_add_assignment (exp_assign (CRC32_ADDRESS, exp_nameop (NAME,"."), false));
+		}
+		polynome32 '(' mustbe_exp ',' mustbe_exp ')'
+		{
+		  lang_add_assignment (exp_assign (CRC32_START, $5, false));
+		  lang_add_assignment (exp_assign (CRC32_END,   $7, false));
+		}
+	| CRC32 TABLE
+		{
+		  lang_add_assignment (exp_assign (CRC32_TABLE, exp_nameop (NAME,"."), false));
+		  lang_add_crc32_table ();
+		}
+	| CRC64
+		{
+		  lang_add_assignment (exp_assign (CRC64_ADDRESS, exp_nameop (NAME,"."), false));
+		}
+		polynome64 '(' mustbe_exp ',' mustbe_exp ')'
+		{
+		  lang_add_assignment (exp_assign (CRC64_START, $5, false));
+		  lang_add_assignment (exp_assign (CRC64_END,   $7, false));
+		}
+	| CRC64 TABLE
+		{
+		  lang_add_assignment (exp_assign (CRC64_TABLE, exp_nameop (NAME,"."), false));
+		  lang_add_crc64_table ();
+		}
+	| TIMESTAMP
+		{
+		  lang_add_timestamp ();
+		}
 	| ASSERT_K
 		{ ldlex_expression (); }
 	  '(' exp ',' NAME ')' separator
@@ -693,9 +729,49 @@ statement:
 		{
 		  ldfile_open_command_file ($2);
 		}
+	| DEBUG ON
+		{
+		  yydebug = 1;
+		}
+	| DEBUG OFF
+		{
+		  yydebug = 0;
+		}
 	  statement_list_opt END
 	;
 
+polynome64:
+	ECMA
+		{
+		  lang_add_crc64_syndrome (false, CRC_POLY_64);
+		}
+	| ISO
+		{
+		  lang_add_crc64_syndrome (false, CRC_POLY_64_ISO);
+		}
+	| POLY mustbe_exp
+		{
+		  lang_add_crc64_syndrome (false, $2->value.value);
+		}
+	| POLYI mustbe_exp
+		{
+		  lang_add_crc64_syndrome (true,  $2->value.value);
+		}
+
+polynome32:
+	CRC32
+		{
+		  lang_add_crc32_syndrome (true,  CRC_POLY_32);
+		}
+	| POLY mustbe_exp
+		{
+		  lang_add_crc32_syndrome (false, $2->value.value);
+		}
+	| POLYI mustbe_exp
+		{
+		  lang_add_crc32_syndrome (true,  $2->value.value);
+		}
+
 statement_list:
 		statement_list statement
 	|	statement
-- 
2.17.1


  parent reply	other threads:[~2023-02-20  9:55 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-19 19:45 [PATCH v4 0/5 Add support for CRC64 generation in linker binutils
2023-02-19 19:45 ` [PATCH v4 1/5] CRC64 commands documentation binutils
2023-02-19 19:50   ` [PATCH v4 0/5] Add support for CRC64 generation in linker Ulf Samuelsson
2023-02-21 12:02     ` Nick Clifton
2023-02-21 13:10       ` Ulf Samuelsson
2023-02-21 13:30       ` Ulf Samuelsson
2023-02-21 12:53   ` [PATCH v4 1/5] CRC64 commands documentation Nick Clifton
2023-02-21 13:24     ` Ulf Samuelsson
2023-02-19 19:45 ` [PATCH v4 2/5] CRC64 testsuite binutils
2023-02-21 12:42   ` Nick Clifton
2023-02-21 15:13     ` Ulf Samuelsson
2023-02-23 10:10       ` Nick Clifton
2023-02-23 10:53         ` Ulf Samuelsson
2023-02-23 11:01           ` Nick Clifton
2023-02-28 11:11         ` Ulf Samuelsson
2023-02-28 12:37           ` Nick Clifton
2023-02-28 13:01             ` Ulf Samuelsson
2023-02-28 13:06               ` Nick Clifton
2023-02-28 14:24                 ` Ulf Samuelsson
2023-02-28 13:45             ` Ulf Samuelsson
2023-02-19 19:45 ` [PATCH v4 3/5] ldlex.l: CRC64 binutils
2023-02-19 19:45 ` binutils [this message]
2023-02-19 19:45 ` [PATCH v4 5/5] Calculate CRC64 over the .text area binutils
2023-02-21 13:26   ` Nick Clifton
2023-02-23  8:36     ` 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=20230219194549.22554-5-binutils@emagii.com \
    --to=binutils@emagii.com \
    --cc=binutils@sourceware.org \
    --cc=nickc@redhat.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).