admin管理员组

文章数量:1208155

What do the symbols mean in this assembly language statement:

.size   _start, . - _start

I've searched and found quite a few identical examples and several variations but none explain what the components mean. The doc says that for ELF the format is .size name , expression. I think it's saying the size is 'something' minus the address of _start. Is that right and, if so, what is the 'something'?

What do the symbols mean in this assembly language statement:

.size   _start, . - _start

I've searched and found quite a few identical examples and several variations but none explain what the components mean. The doc says that for ELF the format is .size name , expression. I think it's saying the size is 'something' minus the address of _start. Is that right and, if so, what is the 'something'?

Share Improve this question asked Jan 19 at 17:08 simgarsimgar 6181 gold badge5 silver badges13 bronze badges 5
  • 3 This sets the symbol size of _start to the size of the function _start when given right after the rnd of the function. – fuz Commented Jan 19 at 17:10
  • @fuz Is rnd a typo for end ? – Sep Roland Commented Jan 19 at 18:26
  • @SepRoland Yes, sorry. – fuz Commented Jan 19 at 18:37
  • A missing part is that this occurs at the end of the 'start' code. Ie, this is what '.' is referring to (the end of start). So, read the line as the 'size' of '_start' is 'end of start - start of start'. The other pseudo op is '.func' which together with '.size' allow debug info to be created. See: stackoverflow.com/questions/57451208/… for extab pseudo-ops. – artless-noise-bye-due2AI Commented Jan 21 at 1:57
  • Extab is an arm method for generating unwind information for aapcs. sourceware.org/binutils/docs-2.21/as/… The pair .size and .func are more for dwarf, etc debug. I mention the extab here as it is conceptually related and these are 'gas' pseudo ops, but they produce elf sections with similar semantics, but different end purposes. Future readers may actually want extab. Also, .fnstart and .fnend might be clearer syntax to some (in link above). – artless-noise-bye-due2AI Commented Jan 21 at 17:51
Add a comment  | 

1 Answer 1

Reset to default 4

I think it's saying the size is 'something' minus the address of _start. Is that right and, if so, what is the 'something'?

That's right, and that 'something' is actually the location counter which is the position in your program that is currently being processed by the assembler. Your particular assembler uses a dot . for this, while many other assemblers use a dollar sign $.

And as @fuz wrote in a comment, if the location counter is currently at the end of the _start function, the difference between the location counter and the address where the function begins gives its size.

本文标签: assemblyWhat does this mean sizestartstart in assemblerStack Overflow