From a4f3f9a244b40e1cb8962b30fba35a8900a37422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Wolker?= Date: Thu, 30 May 2024 16:51:07 +0200 Subject: [PATCH] gas: Fix .asciz directive for multiple operands The documentation stated that this directive inserts a zero byte only after all strings passed as operands to this instructions. Before this commit, zero byte was inserted after each of the strings passed to this directive. Also mentioned this bug in the documentation so users can recpect this bug when using alder version of as. --- gas/doc/as.texi | 3 +++ gas/read.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gas/doc/as.texi b/gas/doc/as.texi index 90898d7479a..d16e706e415 100644 --- a/gas/doc/as.texi +++ b/gas/doc/as.texi @@ -4807,6 +4807,9 @@ a zero byte. The ``z'' in @samp{.asciz} stands for ``zero''. Note that multiple string arguments not separated by commas will be concatenated together and only one final zero byte will be stored. +Note that GNU Assembler version 2.42 (and previous versions) had a bug that +caused inserting a zero byte after each string passed to this directive. + @node Attach_to_group @section @code{.attach_to_group @var{name}} Attaches the current section to the named group. This is like declaring diff --git a/gas/read.c b/gas/read.c index 8026a6cdb65..e898dc9bcbc 100644 --- a/gas/read.c +++ b/gas/read.c @@ -5463,9 +5463,6 @@ stringer (int bits_appendzero) if (*input_line_pointer == '"') break; - if (append_zero) - stringer_append_char (0, bitsize); - #if !defined(NO_LISTING) && defined (OBJ_ELF) /* In ELF, when gcc is emitting DWARF 1 debugging output, it will emit .string with a filename in the .debug section @@ -5505,6 +5502,9 @@ stringer (int bits_appendzero) c = *input_line_pointer; } + if (append_zero) + stringer_append_char (0, bitsize); + demand_empty_rest_of_line (); } -- 2.44.1