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

Jian Cai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 16 13:18:29 PST 2020


jcai19 added a comment.



> https://github.com/ClangBuiltLinux/linux/blob/f01c30de86f1047e9bae1b1b1417b0ce8dcd15b1/arch/arm/probes/kprobes/test-core.h#L114-L116 makes it sounds like `.ascii` and `.asciz` work differently in this regard?

So I played with the two directives a little bit, and I think they both treat a call with multiple string arguments the same as multiple calls with one argument. For example, .ascii produce the same disassembly `"foo" "bar"`, `"foo", "bar"` or `"foobar"` sine the directive does not append anything after string, while .asciz append \0 and turn `"foo" "bar"` or `"foo", "bar"` into `"foo\0bar" `.

With .ascii:

  $ cat test_space.s 
  .ascii "foo" "bar"
  $ cat test_comma.s 
  .ascii "foo", "bar"
  $ cat test_concatenation.s 
  .ascii "foobar"
  
  $ gcc test_space.s -c -o test_space.o
  $ objdump -dr test_space.o
  
  test_space.o:     file format elf64-x86-64
  
  
  Disassembly of section .text:
  
  0000000000000000 <.text>:
     0:	66 6f                	outsw  %ds:(%rsi),(%dx)
     2:	6f                   	outsl  %ds:(%rsi),(%dx)
     3:	62                   	.byte 0x62
     4:	61                   	(bad)  
     5:	72                   	.byte 0x72
  
  $ gcc test_comma.s -c -o test_comma.o
  $ objdump -dr test_comma.o
  
  test_comma.o:     file format elf64-x86-64
  
  
  Disassembly of section .text:
  
  0000000000000000 <.text>:
     0:	66 6f                	outsw  %ds:(%rsi),(%dx)
     2:	6f                   	outsl  %ds:(%rsi),(%dx)
     3:	62                   	.byte 0x62
     4:	61                   	(bad)  
     5:	72                   	.byte 0x72
  
  $ gcc test_concatenation.s -c -o test_concatenation.o
  $ objdump -dr test_concatenation.o
  
  test_concatenation.o:     file format elf64-x86-64
  
  
  Disassembly of section .text:
  
  0000000000000000 <.text>:
     0:	66 6f                	outsw  %ds:(%rsi),(%dx)
     2:	6f                   	outsl  %ds:(%rsi),(%dx)
     3:	62                   	.byte 0x62
     4:	61                   	(bad)  
     5:	72                   	.byte 0x72
  
     4:	Address 0x0000000000000004 is out of bounds.

With .asciz:

  $ cat test_space.s 
  .asciz "foo" "bar"
  $ cat test_comma.s 
  .asciz "foo", "bar"
  $ cat test_concatenation.s 
  .asciz "foo\0bar"
  
  $ gcc test_space.s -c -o test_space.o
  $ objdump -dr test_space.o
  
  test_space.o:     file format elf64-x86-64
  
  
  Disassembly of section .text:
  
  0000000000000000 <.text>:
     0:	66 6f                	outsw  %ds:(%rsi),(%dx)
     2:	6f                   	outsl  %ds:(%rsi),(%dx)
     3:	00 62 61             	add    %ah,0x61(%rdx)
     6:	72 00                	jb     0x8
  
  $ gcc test_comma.s -c -o test_comma.o
  $ objdump -dr test_comma.o
  
  test_comma.o:     file format elf64-x86-64
  
  
  Disassembly of section .text:
  
  0000000000000000 <.text>:
     0:	66 6f                	outsw  %ds:(%rsi),(%dx)
     2:	6f                   	outsl  %ds:(%rsi),(%dx)
     3:	00 62 61             	add    %ah,0x61(%rdx)
     6:	72 00                	jb     0x8
  
  
  $ gcc test_concatenation.s -c -o test_concatenation.o
  $ objdump -dr test_concatenation.o
  
  Disassembly of section .text:
  
  0000000000000000 <.text>:
     0:	66 6f                	outsw  %ds:(%rsi),(%dx)
     2:	6f                   	outsl  %ds:(%rsi),(%dx)
     3:	00 62 61             	add    %ah,0x61(%rdx)
     6:	72 00                	jb     0x8




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