.ascii/.asciz: juxtaposition and comma

Jan Beulich jbeulich@suse.com
Tue Nov 17 12:41:58 GMT 2020


On 17.11.2020 12:56, Nick Clifton via Binutils wrote:
>> % 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.

And is it normal that no comma still separate arguments? I
suppose this is traditional behavior for macro arguments (but
even there I consider is questionable), but I'd expect
directives to be less "relaxed" in how arguments can be
specified. IOW if the strings aren't concatenated in the case
here, I'd have expected a syntax error instead.

Jan


More information about the Binutils mailing list