[PATCH] D91460: [AsmParser] make .ascii/.asciz/.string support multiple strings

Jessica Clarke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 13 21:08:14 PST 2020


jrtc27 added a comment.

In D91460#2395521 <https://reviews.llvm.org/D91460#2395521>, @jcai19 wrote:

>> In which case I assume `.asciz "foo" "bar"` is equivalent to `.asciz "foobar"` rather than `.asciz "foo\0bar"` (same for `.string`), just like C string concatenation, and hence why both syntaxes exist?
>
> I think GNU assembler would produce the same disassembly with `.asciz "foo" "bar"` and `.asciz "foo", "bar"`.
>
>   $ cat test.s 
>   .asciz "foo" "bar"
>   .asciz "foo", "bar"
>   
>   $ arm-linux-gnueabihf-gcc test.s -c -o test.o
>   $ arm-linux-gnueabihf-objdump -dr test.o
>   gcc.o:     file format elf32-littlearm
>   
>   
>   Disassembly of section .text:
>   
>   00000000 <.text>:
>      0:	006f6f66 	.word	0x006f6f66
>      4:	00726162 	.word	0x00726162
>      8:	006f6f66 	.word	0x006f6f66
>      c:	00726162 	.word	0x00726162

In which case that's confusing and likely to lead to bugs if people make use of the preprocessor in the hopes of concatenating strings but end up with NUL bytes being inserted contrary to what there would be in C. Can we not just fix the assembly to use commas rather than this weird syntax that seems to be a special case for `.asciz`? You can't write `.word 2 2`, only `.word 2, 2`, so why do string directives really need special treatment?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91460/new/

https://reviews.llvm.org/D91460



More information about the llvm-commits mailing list