From patchwork Sun Feb 19 17:34:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Samuelsson X-Patchwork-Id: 59334 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1224233wrn; Mon, 20 Feb 2023 02:07:33 -0800 (PST) X-Google-Smtp-Source: AK7set8Dm24jealvPPmGEJaXc0OlnhOmyD0qIjO7WhnreFAiqc6LF+AYecIb8HZ15An3MSmOXk6b X-Received: by 2002:a17:906:9f25:b0:8b1:7569:ad58 with SMTP id fy37-20020a1709069f2500b008b17569ad58mr5347265ejc.2.1676887653067; Mon, 20 Feb 2023 02:07:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676887653; cv=none; d=google.com; s=arc-20160816; b=FrAxXl9HU/CqMSYPuk8PLPNEQogFSk9uJ/iqCNulgWMC3rfP5KWJ6K1TonjHbi5OHX w+R5dYE4wZIh2NnccunQs2F+oxc8pvbZHMbXHNLqVZHnzkQvI72hh3mqk4etYeHRLThk iFsShm2DHvhFv1523u17jYM7aeBJhChtj9p+X/kcB7Vab+Cqvv7m9l132EpGLECvkr4k fR3/i7GLoCPo37vPwmdrfzoTfp5bneYh3oZASesfcP83vc30w1yr/YOU/L5mL4IkEdec cuZd+7DVapmiKamcaxGNd7RjOjYzmYwfK9L0W5Qc1LsmBuVdekB9bNANZyN8kX17PyWP 040w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=H1iaqLjL/vicvMfCcmgNJdZ314sbTJRh28G/ObGUACo=; b=gBpCD3vlTp0mk6lH+lrK6R82MNtOpRSKyr4aadHO2DcTR+2yuJHozxIAJYBW2DGe9j 3NaJeEV4Vhc/y4hrtdXf9DLX+EvXCaWokaWPI0oz0zcYz8WdbR3tc/izSuHKx/8wRr2K tDbVlZ7oy+PlHVft/+EhuGF9s8FOwH0ZQ7nkiBqeGzCC8qqi9K3CHCnOvMukl8NzIwh1 qPhVFReP5nwHzhO5d2lo7Uo3xBx0yIOwu0JBi+f+uXppTUVGigMwu7KAzsKYBjBxtQBv eRAbbc41P39RenkRugIMbWN7mFbLIj0JwprSyeQnrZzIuSuZXV/vJIbrxGTmLNIIfRLd 1mYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=O+Bn6Ylz; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id vw13-20020a170907058d00b008d5952195f6si2026088ejb.252.2023.02.20.02.07.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 02:07:33 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=O+Bn6Ylz; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AFC83395B458 for ; Mon, 20 Feb 2023 10:01:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AFC83395B458 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676887289; bh=H1iaqLjL/vicvMfCcmgNJdZ314sbTJRh28G/ObGUACo=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=O+Bn6YlznoKg4mof1uYRt7IIN4vbYaE8hY/d8amQnyDX6SpFSfllEL4JTqDJSdXt3 OcJ+UB08o+xdxwK5dKkrrnNuJznC2HJR9DN/KaF2mn6HDNgIXMEW59GMIAhZXAaSDK Zd0jMOPXgvRpQNgu4aDEboUtpMz4j3hyLTdI4Sqs= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from emagii.se (www.emagii.com [185.133.207.17]) by sourceware.org (Postfix) with ESMTPS id 90B9C3893676 for ; Mon, 20 Feb 2023 10:00:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 90B9C3893676 Received: from valinor.ownit.se (84-55-68-216.customers.ownit.se [84.55.68.216]) by emagii.se (Postfix) with ESMTPSA id CE8051201B0; Sun, 19 Feb 2023 18:34:54 +0100 (CET) Received-SPF: pass (emagii.beebytevps.io: connection is authenticated) To: binutils@sourceware.org Cc: nickc@redhat.com, Ulf Samuelsson Subject: [PATCH v3 1/5] CRC64 commands documentation Date: Sun, 19 Feb 2023 18:34:46 +0100 Message-Id: <20230219173450.25555-2-binutils@emagii.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230219173450.25555-1-binutils@emagii.com> References: <20230219173450.25555-1-binutils@emagii.com> X-PPP-Message-ID: <167682809512.629621.10551407631772870309@localhost.localdomain> X-PPP-Vhost: emagii.com X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_FAIL, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Ulf Samuelsson via Binutils From: Ulf Samuelsson Reply-To: binutils@emagii.com Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758344147891710905?= X-GMAIL-MSGID: =?utf-8?q?1758344147891710905?= From: Ulf Samuelsson * LIBCRC license * NEWS * ls.texi Signed-off-by: Ulf Samuelsson --- COPYING.CRC64 | 42 +++++++++++++++ ld/NEWS | 47 +++++++++++++++++ ld/ld.texi | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 229 insertions(+) create mode 100755 COPYING.CRC64 diff --git a/COPYING.CRC64 b/COPYING.CRC64 new file mode 100755 index 00000000000..618e1c63dae --- /dev/null +++ b/COPYING.CRC64 @@ -0,0 +1,42 @@ +The GNU linker contains CRC routines that are used to implement the +CRC64 command in the output section. + +The CRC routines are extracted from LIBCRC available at + +They are used to +* https://www.libcrc.org/ +* https://github.com/lammertb/libcrc/tree/v2.0 + + +/* + * Library: libcrc + * File: src/crc64.c + * Author: Lammert Bies + * + * This file is licensed under the MIT License as stated below + * + * Copyright (c) 2016 Lammert Bies + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Description + * ----------- + * The source file src/crc64.c contains the routines which are needed to + * calculate a 64 bit CRC value of a sequence of bytes. + */ diff --git a/ld/NEWS b/ld/NEWS index 4b91f2c3b0a..8c1203a3c2e 100644 --- a/ld/NEWS +++ b/ld/NEWS @@ -1,5 +1,52 @@ -*- text -*- +* The linker script has a new command to insert a timestamp + TIMESTAMP + inserts the current time (seconds since Epoch) as a 64-bit value + +* The linker script syntax has new commands for debugging a linker script + DEBUG ON turns on debugging + DEBUG OFF turns off debugging + +* The linker script syntax has new commands for handling CRC-32/64 calculations + on the '.text' section + It uses code from https://www.libcrc.org/ + + CRC32 CRC32 (start, end) + CRC32 POLY (polynome)(start, end) + CRC32 POLYI(polynome)(start, end) (inversion during CRC calculation) + CRC64 ECMA (start, end) + CRC64 ISO (start, end) + CRC64 POLY (polynome)(start, end) + CRC64 POLYI(polynome)(start, end) (inversion during CRC calculation) + CRC64 TABLE + + The CRC32, ECMA, ISO, POLY and POLYI defines the polynome to use + and reserves space for the 32/64-bit CRC in the '.text' section. + The default polynome is the ECMA. + + The CRC32 command defines some global symbols. + ___CRC32___ is the address of the CRC64 checksum + ___CRC32_START___ is the address where CRC calculation starts + ___CRC32_END___ The CRC calculation ends before this address. + + The CRC64 command defines some global symbols. + ___CRC64___ is the address of the CRC64 checksum + ___CRC64_START___ is the address where CRC calculation starts + ___CRC64_END___ The CRC calculation ends before this address. + + All three symbols must refer to addresses in the '.text' section. + If they are defined at the end of the linking process, then + the CRC## will be calculated between ___CRC##_START___ .. ___CRC##_END___ -1 + and the result will be inserted at ___CRC##___. + ___CRC##___ must be outside the region where CRC is calculated + + The CRC32/64 TABLE command generates a table for CRC generation. + This is not neccessary, but will speed up the calculation + and makes it compatible with the CRC check routines at https://www.libcrc.org/ + It defines the ___CRC##_TABLE___ symbol at the start of the table. + The user may choose to add this table to his code instead of using the linker. + * The linker script syntax has two new commands for inserting text into output sections: ASCII () "string" diff --git a/ld/ld.texi b/ld/ld.texi index 7802f0661b0..2042fadb33e 100644 --- a/ld/ld.texi +++ b/ld/ld.texi @@ -5394,6 +5394,146 @@ area: ASCIZ "This is 16 bytes" @end smallexample +@cindex output section strings +@kindex CRC32 CRC32 (@var{expression}, @var{expression}) +@kindex CRC32 POLY (@var{expression})(@var{expression}, @var{expression}) +@kindex CRC32 POLYI (@var{expression})(@var{expression}, @var{expression}) +@kindex CRC64 ECMA (@var{expression}, @var{expression}) +@kindex CRC64 ISO (@var{expression}, @var{expression}) +@kindex CRC64 POLY (@var{expression})(@var{expression}, @var{expression}) +@kindex CRC64 POLYI (@var{expression})(@var{expression}, @var{expression}) + +You can calculate the CRC of a part of the '.text' section through the +@code{CRC32} and @code{CRC64} commands. +The commands take a parameter for the @code{polynome} and then two more, +specifying range of the checked area. The end address is the first address +past the checked area. + +There is one predefined 43-bit polynomes + +* @code{CRC32} @code{0xEDB88320} + +There are two predefined 64-bit polynomes + +* @code{ECMA} @code{0x42F0E1EBA9EA3693} + +* @code{ISO} @code{0xD800000000000000} + +You can also select your own @code{polynome} using the @code{CRCxx POLY} or +@code{CRCxx POLYI}. The @code{POLYI} will invert the polynome before and after +the calculation which is neccessary for the @code{CRC64-WE} algorithm + +The default 64-bit polynome is the @code{ECMA} + +The CRC32 command defines some global symbols. + +* @code{___CRC32___} address of the CRC32 checksum + +* @code{___CRC32_START___} first address in the checked area. + +* @code{___CRC32_END___} first address past the checked area. + +The CRC64 command defines some global symbols. + +* @code{___CRC64___} address of the CRC64 checksum + +* @code{___CRC64_START___} first address in the checked area. + +* @code{___CRC64_END___} first address past the checked area. + +Note: The generated CRC value must be stored outside the checked area. + +Example 1: This request a CRC check using the @code{ECMA} algorithm + +@smallexample + CRC = '.'; + CRC64 ECMA (START_CHECK,END_TEXT) + START_CHECK = '.'; +@end smallexample + +The user can retrieve the CRC value through the @code{CRC} label. + +Example 2: This request a CRC check using the @code{ISO} algorithm + +@smallexample + CRC = '.'; + CRC64 ISO (START_CHECK,END_TEXT) + START_CHECK = '.'; +@end smallexample + +The user can retrieve the CRC value through the @code{CRC} label. + +Example 3: This request a CRC check using a user defined @code{polynome} + +@smallexample + CRC = '.'; + CRC64 POLY (0xDEADBEEFDEADBEEF) (START_CHECK,END_TEXT) + START_CHECK = '.'; +@end smallexample + +The user can retrieve the CRC value through the @code{CRC} label. + +Example 4: This request a CRC check using a user defined @code{polynome} + The @code{polynome} is inverted before use, and teh result is inverted. + +@smallexample + CRC = '.'; + CRC64 POLYI (0xDEADBEEFDEADBEEF) (START_CHECK,END_TEXT) + START_CHECK = '.'; +@end smallexample + +Example 5: This request a CRC check using a user defined @code{CRC32} + +@smallexample + CRC = '.'; + CRC32 CRC32 (START_CHECK,END_TEXT) + START_CHECK = '.'; +@end smallexample + +The user can retrieve the CRC value through the @code{CRC} label. + +@cindex output section strings +@kindex CRC32 TABLE + +The @code{CRC32 TABLE} command creates a 1 kByte table for a table-driven +CRC calculation. This speeds up the CRC calculation over a non-table-driver +version since you can handle 8 bits at a time, instead of 1 bit. + +The table generated is for the @code{polynome} selected using a @code{CRC32} +command. + +Example 1: Generate a 1 kB table +@smallexample + mytable = '.'; + CRC32 TABLE +@end smallexample + +The user can declare @code{extern uint32_t *mytable;} in his code to use it. + +@cindex output section strings +@kindex CRC64 TABLE + +The @code{CRC64 TABLE} command creates a 2 kByte table for a table-driven +CRC calculation. This speeds up the CRC calculation over a non-table-driver +version since you can handle 8 bits at a time, instead of 1 bit. + +The table generated is for the @code{polynome} selected using a @code{CRC64} +command. If no @code{CRC64} command has been emitted, the @code{ECMA} is used. + +Example 1: Generate a 2 kB table +@smallexample + mytable = '.'; + CRC64 TABLE +@end smallexample + +The user can declare @code{extern uint64_t *mytable;} in his code to use it. + +@cindex output section strings +@kindex TIMESTAMP + +The @code{TIMESTAMP} command creates 64-bit integer with the number of seconds +since Epoch (1970-01-01 00:00) + @kindex FILL(@var{expression}) @cindex holes, filling @cindex unspecified memory