What is zero in GNU gas?

萝らか妹 提交于 2021-01-27 13:58:40

问题


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?


回答1:


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 :-)



来源:https://stackoverflow.com/questions/65641034/what-is-zero-in-gnu-gas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!