From 3d955acb36f483c05724181da5ffba46b1303c43 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Tue, 17 Nov 2020 15:45:01 +0000 Subject: [PATCH] When reading string arguments for the assembler's string directives treat space separated strings as a single entity. * read.c (stringer): Treat space separated, quote enclosed strings as a single string. * doc/as.texi (asciz): Mention this behaviour in the description of the asciz directive. * testsuite/gas/all/asciz.s: New test. * testsuite/gas/all/asciz.d: New test driver. * testsuite/gas/all/gas.exp: Run the new test. --- gas/doc/as.texi | 4 +++- gas/read.c | 5 +++++ gas/testsuite/gas/all/asciz.d | 10 ++++++++++ gas/testsuite/gas/all/asciz.s | 2 ++ gas/testsuite/gas/all/gas.exp | 1 + 5 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 gas/testsuite/gas/all/asciz.d create mode 100644 gas/testsuite/gas/all/asciz.s diff --git a/gas/doc/as.texi b/gas/doc/as.texi index 4d5294552ad..278de41afc6 100644 --- a/gas/doc/as.texi +++ b/gas/doc/as.texi @@ -4662,7 +4662,9 @@ trailing zero byte) into consecutive addresses. @cindex zero-terminated strings @cindex null-terminated strings @code{.asciz} is just like @code{.ascii}, but each string is followed by -a zero byte. The ``z'' in @samp{.asciz} stands for ``zero''. +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. @node Attach_to_group @section @code{.attach_to_group @var{name}} diff --git a/gas/read.c b/gas/read.c index 7fd9af05fad..9ba61cd96f4 100644 --- a/gas/read.c +++ b/gas/read.c @@ -5468,6 +5468,11 @@ stringer (int bits_appendzero) while (is_a_char (c = next_char_of_string ())) stringer_append_char (c, bitsize); + /* Treat "a" "b" as "ab". Even if we are appending zeros. */ + SKIP_ALL_WHITESPACE (); + if (*input_line_pointer == '"') + break; + if (append_zero) stringer_append_char (0, bitsize); diff --git a/gas/testsuite/gas/all/asciz.d b/gas/testsuite/gas/all/asciz.d new file mode 100644 index 00000000000..afba96bddaa --- /dev/null +++ b/gas/testsuite/gas/all/asciz.d @@ -0,0 +1,10 @@ +#objdump: -s -j .data -j "\$DATA\$" +#name: Generation of NUL terminated strings +# The TIC4x and TIC5x assemblers do not support the concatenation of space separated strings. +#xfail: tic4*-* tic5*-* + +.*: +file format .* + +Contents of section (\.data|\$DATA\$): +.*ab\.cd\..* +#pass diff --git a/gas/testsuite/gas/all/asciz.s b/gas/testsuite/gas/all/asciz.s new file mode 100644 index 00000000000..eb66ee6e6c0 --- /dev/null +++ b/gas/testsuite/gas/all/asciz.s @@ -0,0 +1,2 @@ + .data + .asciz "a" "b", "c" "d" diff --git a/gas/testsuite/gas/all/gas.exp b/gas/testsuite/gas/all/gas.exp index af9cb61e3f8..47515bf769e 100644 --- a/gas/testsuite/gas/all/gas.exp +++ b/gas/testsuite/gas/all/gas.exp @@ -473,3 +473,4 @@ run_dump_test "fill-1" gas_test "pr23938.s" "" "" ".xstabs" run_dump_test "nop" +run_dump_test "asciz" -- 2.30.2