.ascii/.asciz: juxtaposition and comma

Nick Clifton nickc@redhat.com
Tue Nov 17 11:56:36 GMT 2020


Hi Fangrui,

> % cat a.s
> .asciz "a", "b" "c", "d"
> .ascii "e", "f" "g", "h"
> % as a.s -o a.o
> % readelf -x .text a.o
> 
> Hex dump of section '.text':
>    0x00000000 61006200 63006400 65666768          a.b.c.d.efgh

This is the intended behaviour of *both* directives.

The .ascii directive places is string arguments into the destination
section *without* any terminating NUL bytes.  Hence multiple arguments
to .ascii appear as a single concatenated sequence when examined, and
there is no NUL at the end of them.

The .asciz directive does exactly the same, except that each of its
arguments is treated as a NUL terminated string, and the NUL is stored
along with the rest of the bytes.  Hence when examined by tools like
readelf you will see one NUL byte for each string argument given to
.asciz.

Cheers
   Nick



More information about the Binutils mailing list