From patchwork Mon Jul 8 17:49:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Samuelsson X-Patchwork-Id: 93547 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CF948384A49D for ; Mon, 8 Jul 2024 17:51:10 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from morgoth (host183-192-94.customer.mediateknik.net [193.183.192.94]) by sourceware.org (Postfix) with ESMTP id 991A538654B3 for ; Mon, 8 Jul 2024 17:49:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 991A538654B3 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=emagii.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=morgoth ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 991A538654B3 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=193.183.192.94 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720460974; cv=none; b=L1zqmKT9apcnqFgQRITJ91ZMV3sEEMdH7BeJVDsiZhMGFlgiP2i8nVxSGAIkRav+iEOS2AXJzt1dAwRImzRJ/eqZAt/2Sc2EXro4+hyft1/kwqFk23cF3g2o70x5PVQcWo7nsVN2XoBU4sJapIcLbeG4MOn6+JBj8FcC+xuBV3I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720460974; c=relaxed/simple; bh=2egBCLSYUelwUVcODlgb2aRnG9KIgfNUd0U0RAfEODg=; h=From:To:Subject:Date:Message-Id; b=w3s36/mXvCEbUbNycbBPnW1zK+5wG8SPTcZnhTj7drwidOJ1/QgpT3iIA9XNRBKuU9GhUVUtS5bCvl3koI5wLXmuEP0R3gBZlNZ67DQ5JEDXwqsVkZijC0EcjMH+FEyEodxJ32Gogi/rJTH59o1REp/34hfuq/6FPqn73KN4apo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by morgoth (Postfix, from userid 1000) id 101A2340BED; Mon, 8 Jul 2024 19:49:32 +0200 (CEST) From: binutils@emagii.com To: binutils@sourceware.org Cc: nickc@redhat.com, Ulf Samuelsson Subject: [PATCH v4 4/7] ld.texi: Add ASCII to info file Date: Mon, 8 Jul 2024 19:49:26 +0200 Message-Id: <20240708174929.15137-5-binutils@emagii.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240708174929.15137-1-binutils@emagii.com> References: <20240708174929.15137-1-binutils@emagii.com> X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, FSL_HELO_NON_FQDN_1, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, HELO_NO_DOMAIN, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KHOP_HELO_FCRDNS, SPF_NONE, TXREP autolearn=ham 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.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org From: Ulf Samuelsson Signed-off-by: Ulf Samuelsson --- ld/ld.texi | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/ld/ld.texi b/ld/ld.texi index 89e3913317a..70ff492ab2b 100644 --- a/ld/ld.texi +++ b/ld/ld.texi @@ -5642,7 +5642,8 @@ C identifiers because they contain a @samp{.} character. @cindex data @cindex section data @cindex output section data -@kindex ASCIZ ``@var{string}'' +@kindex ASCIZ "@var{string}" +@kindex ASCII @var{expression}, "@var{string}" @kindex BYTE(@var{expression}) @kindex SHORT(@var{expression}) @kindex LONG(@var{expression}) @@ -5681,7 +5682,7 @@ endianness of the first input object file. You can include a zero-terminated string in an output section by using @code{ASCIZ}. The keyword is followed by a string which is stored at -the current value of the location counter adding a zero byte at the +the current value of the location counter adding a NUL byte at the end. If the string includes spaces it must be enclosed in double quotes. The string may contain '\n', '\r', '\t' and octal numbers. Hex numbers are not supported. @@ -5691,6 +5692,43 @@ For example, this string of 16 characters will create a 17 byte area ASCIZ "This is 16 bytes" @end smallexample +You can include a fixed size string in an output section by using +@code{ASCII}. The keyword is followed by a size and a string +separated by a comma. The string is stored at the current +value of the location counter. If the string is shorted than the allocated +size, NUL character are added at the end to fill up to the specified size. +Note the fill value is ignored for this padding. +If the string includes spaces it must be enclosed in double +quotes. The string may contain '\n', '\r', '\t' and octal numbers. +Hex numbers are not supported. + +If the string is too long, a warning is issued and the string is +truncated. The string will still be zero-terminated in this case. + +If the expression evaluates to zero then the directive will be treated +as if it were @code{ASCIZ} instead. + +Example: This is string of 16 characters and will create a 16 byte +area, not zero-terminated. +@smallexample + ASCII 16, "This is 16 bytes" +@end smallexample + + +Example: This is string of 10 characters in a 16 byte area, unused locations are filled with NUL characters. +@smallexample + ASCII 16, "This is 16" +@end smallexample + + +Example: This is string of 15 characters in a 16 byte area, ending with a NUL character. +@smallexample + ASCII 16, "01234567890123456789" +@end smallexample +The last character of the string will be "4". +A warning will be issued to indicate that the string does not fit. + + Note---these commands only work inside a section description and not between them, so the following will produce an error from the linker: @smallexample