public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v1 0/5 Add support for CRC64 generation in linker
@ 2023-02-17 11:20 binutils
  2023-02-17 11:20 ` [PATCH v1 1/5] ldlex.l: CRC64 binutils
  2023-02-17 11:20 ` [PATCH v1 2/5] ldgram.y: CRC64 binutils
  0 siblings, 2 replies; 4+ messages in thread
From: binutils @ 2023-02-17 11:20 UTC (permalink / raw)
  To: binutils; +Cc: nickc

Supports the following new linker commands:
* CRC64 ECMA                     '(' crc_start ',' crc_end ')'
* CRC64 ISO                      '(' crc_start ',' crc_end ')'
* CRC64 POLY  '[' mustbe_exp ']' '(' crc_start ',' crc_end ')'
* CRC64 POLYI '[' mustbe_exp ']' '(' crc_start ',' crc_end ')'
* CRC64 TABLE

ECMA  == 0x42F0E1EBA9EA3693
ISO   == 0xD800000000000000
POLY  == Allows your own polynome
POLYI == Allows your own polynome, with inversion during calc

The CRC is calculated from crc_start to crc_end (not included)

The "CRC64 <polynome> command
* Allows specifying the polynom (ECMA(default), ISO or your own)
* Allows for inversion in the CRC calculation (CRC64-WE)
* Allows specifying the area that should be checked.
* reserves room for the CRC (8 bytes)
* Declares a symbol ___CRC64___ for the address of the CRC.
* Declares a symbol ___CRC64_START___ for the first address of the checked area
* Declares a symbol ___CRC64_END___ for the first address after the checked area

The CRC TABLE command
  This is used to speed up the CRC calculation.
* Creates a 2kB table which speeds up the CRC calculation
* Can insert the 2kB table into the .text section at current location.
* Declares a symbol ___CRC64_TABLE___ if the table is inserted.

Comments on the code:
This version also supports the
* DEBUG ON
* DEBUG OFF
turning on/off yydebug


The ld.texi stuff needs some work. Not very experienced with that.

Added enty in NEWS

Added 4 test cases for the different CRC64 polynome commands.

The code is using the libcrc released under an MIT license found in
* https://www.libcrc.org/
* https://github.com/lammertb/libcrc/tree/v2.0
Author:  Lammert Bies
A license for libcrc is added to the patch.

[PATCH v1 1/5] ldlex.l: CRC64
[PATCH v1 2/5] ldgram.y: CRC64
[PATCH v1 3/5] Calculate CRC64 over the .text area
[PATCH v1 4/5] CRC64 commands documentation
[PATCH v1 5/5] CRC64 testsuite


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v1 1/5] ldlex.l: CRC64
  2023-02-17 11:20 [PATCH v1 0/5 Add support for CRC64 generation in linker binutils
@ 2023-02-17 11:20 ` binutils
  2023-02-17 11:20 ` [PATCH v1 2/5] ldgram.y: CRC64 binutils
  1 sibling, 0 replies; 4+ messages in thread
From: binutils @ 2023-02-17 11:20 UTC (permalink / raw)
  To: binutils; +Cc: nickc, Ulf Samuelsson

From: Ulf Samuelsson <binutils@emagii.com>

Signed-off-by: Ulf Samuelsson <binutils@emagii.com>
---
 ld/ldlex.l | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/ld/ldlex.l b/ld/ldlex.l
index 910e7ea3b8b..a8c95e66f7b 100644
--- a/ld/ldlex.l
+++ b/ld/ldlex.l
@@ -298,6 +298,15 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
 <SCRIPT>"AFTER"				{ RTOKEN(AFTER); }
 <SCRIPT>"BEFORE"			{ RTOKEN(BEFORE); }
 <WILD>"FILL"				{ RTOKEN(FILL); }
+<WILD>"CRC64"				{ RTOKEN(CRC64); }
+<WILD>"ECMA"				{ RTOKEN(ECMA); }
+<WILD>"ISO"					{ RTOKEN(ISO); }
+<WILD>"POLY"				{ RTOKEN(POLY); }
+<WILD>"POLYI"				{ RTOKEN(POLYI); }
+<WILD>"TABLE"				{ RTOKEN(TABLE); }
+<WILD>"DEBUG"				{ RTOKEN(DEBUG); }
+<WILD>"ON"					{ RTOKEN(ON); }
+<WILD>"OFF"					{ RTOKEN(OFF); }
 <SCRIPT>"STARTUP"			{ RTOKEN(STARTUP); }
 <SCRIPT>"OUTPUT_FORMAT"			{ RTOKEN(OUTPUT_FORMAT); }
 <SCRIPT>"OUTPUT_ARCH"			{ RTOKEN(OUTPUT_ARCH); }
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v1 2/5] ldgram.y: CRC64
  2023-02-17 11:20 [PATCH v1 0/5 Add support for CRC64 generation in linker binutils
  2023-02-17 11:20 ` [PATCH v1 1/5] ldlex.l: CRC64 binutils
@ 2023-02-17 11:20 ` binutils
  1 sibling, 0 replies; 4+ messages in thread
From: binutils @ 2023-02-17 11:20 UTC (permalink / raw)
  To: binutils; +Cc: nickc, Ulf Samuelsson

From: Ulf Samuelsson <binutils@emagii.com>

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

diff --git a/ld/ldgram.y b/ld/ldgram.y
index faffeec94b8..d543d47a5ef 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,8 @@ 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 ECMA ISO POLY POLYI TABLE
+%token DEBUG ON OFF
 %token '{' '}'
 %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
 %token INHIBIT_COMMON_ALLOCATION FORCE_GROUP_ALLOCATION
@@ -682,6 +685,28 @@ statement:
 		{
 		  lang_add_fill ($3);
 		}
+	| DEBUG ON
+		{
+			yydebug = 1;
+		}
+	| DEBUG OFF
+		{
+			yydebug = 0;
+		}
+	| CRC64
+		{
+		  lang_add_assignment (exp_assign (CRC_ADDRESS, exp_nameop (NAME,"."), false));
+		}
+		polynome '(' mustbe_exp ',' mustbe_exp ')'
+		{
+		  lang_add_assignment (exp_assign (CRC_START, $5, false));
+		  lang_add_assignment (exp_assign (CRC_END,   $7, false));
+		}
+	| CRC64 TABLE
+		{
+		  lang_add_assignment (exp_assign (CRC_TABLE, exp_nameop (NAME,"."), false));
+		  lang_add_crc_table();
+		}
 	| ASSERT_K
 		{ ldlex_expression (); }
 	  '(' exp ',' NAME ')' separator
@@ -696,6 +721,25 @@ statement:
 	  statement_list_opt END
 	;
 
+polynome:
+	  ECMA
+		{
+		  lang_add_crc_syndrome(false, CRC_POLY_64);
+		}
+	| ISO
+		{
+		  lang_add_crc_syndrome(false, CRC_POLY_64_ISO);
+		}
+	| POLY mustbe_exp
+		{
+		  lang_add_crc_syndrome(false, $2->value.value);
+		}
+		
+	| POLYI mustbe_exp
+		{
+		  lang_add_crc_syndrome(true,  $2->value.value);
+		}
+
 statement_list:
 		statement_list statement
 	|	statement
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v1 2/5] ldgram.y: CRC64
  2023-02-17 13:54 [PATCH v1 0/5 Add support for CRC64 generation in linker binutils
@ 2023-02-17 13:54 ` binutils
  0 siblings, 0 replies; 4+ messages in thread
From: binutils @ 2023-02-17 13:54 UTC (permalink / raw)
  To: binutils; +Cc: nickc, Ulf Samuelsson

From: Ulf Samuelsson <binutils@emagii.com>

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

diff --git a/ld/ldgram.y b/ld/ldgram.y
index faffeec94b8..d543d47a5ef 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,8 @@ 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 ECMA ISO POLY POLYI TABLE
+%token DEBUG ON OFF
 %token '{' '}'
 %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
 %token INHIBIT_COMMON_ALLOCATION FORCE_GROUP_ALLOCATION
@@ -682,6 +685,28 @@ statement:
 		{
 		  lang_add_fill ($3);
 		}
+	| DEBUG ON
+		{
+			yydebug = 1;
+		}
+	| DEBUG OFF
+		{
+			yydebug = 0;
+		}
+	| CRC64
+		{
+		  lang_add_assignment (exp_assign (CRC_ADDRESS, exp_nameop (NAME,"."), false));
+		}
+		polynome '(' mustbe_exp ',' mustbe_exp ')'
+		{
+		  lang_add_assignment (exp_assign (CRC_START, $5, false));
+		  lang_add_assignment (exp_assign (CRC_END,   $7, false));
+		}
+	| CRC64 TABLE
+		{
+		  lang_add_assignment (exp_assign (CRC_TABLE, exp_nameop (NAME,"."), false));
+		  lang_add_crc_table();
+		}
 	| ASSERT_K
 		{ ldlex_expression (); }
 	  '(' exp ',' NAME ')' separator
@@ -696,6 +721,25 @@ statement:
 	  statement_list_opt END
 	;
 
+polynome:
+	  ECMA
+		{
+		  lang_add_crc_syndrome(false, CRC_POLY_64);
+		}
+	| ISO
+		{
+		  lang_add_crc_syndrome(false, CRC_POLY_64_ISO);
+		}
+	| POLY mustbe_exp
+		{
+		  lang_add_crc_syndrome(false, $2->value.value);
+		}
+		
+	| POLYI mustbe_exp
+		{
+		  lang_add_crc_syndrome(true,  $2->value.value);
+		}
+
 statement_list:
 		statement_list statement
 	|	statement
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-02-17 13:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-17 11:20 [PATCH v1 0/5 Add support for CRC64 generation in linker binutils
2023-02-17 11:20 ` [PATCH v1 1/5] ldlex.l: CRC64 binutils
2023-02-17 11:20 ` [PATCH v1 2/5] ldgram.y: CRC64 binutils
2023-02-17 13:54 [PATCH v1 0/5 Add support for CRC64 generation in linker binutils
2023-02-17 13:54 ` [PATCH v1 2/5] ldgram.y: CRC64 binutils

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