Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is .zero in GNU gas?

In the following compiler output:

a:
        .long   4
b:
        .byte   99
x:
        .zero   4
c:
        .byte   12
f:
        .zero   4

What does the .zero directive mean? It seems to be the only one not listed in the gas directives. Just from looking at the above, long is four bytes, .byte is one byte, and I'm guessing .zero means zero-for-four-bytes (or whatever the number is after the directive). Is that correct?

If so, why not just do .long 0. Does this put it in a different section or something?

like image 244
samuelbrody1249 Avatar asked Oct 17 '25 13:10

samuelbrody1249


1 Answers

No, it doesn't put it in a different section, it just puts it inline in whatever section you're currently creating.

In terms of its relationship to .long, the latter actually depends on the architecture. It could be a different size and/or endianness. Note the endianness probably won't matter for the zero value but the size may.

The .zero directive, on the other hand, is an alias for .skip (and .space on some architectures), and generates the requested number of bytes regardless of architecture.

Also keep in mind that, as an alias of .skip, you can also provide the value you want used for the bytes (it defaults to zero) but it makes little sense to do something like:

.zero 4, 32

to generate four spaces :-)

like image 57
paxdiablo Avatar answered Oct 21 '25 05:10

paxdiablo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!