Reputation: 51
My question is about the use of the .size operator in ARM CORTEX M startup files like this startup script.
I have read other questions on the .size operator and my understanding is that the following line :
.size X,.-X
allows to define the size of X by the distance between the current location (.) and the definition of the symbol X.
This is ok when this line is used at the end of the X definition. No problem with that. But how can it work when it is used before the symbol ?
At line 94 of the startup script, you can read :
.section .isr_vector,"a",%progbits
.type g_pfnVectors, %object
.size g_pfnVectors, .-g_pfnVectors
g_pfnVectors:
.word _estack
.word Reset_Handler
[...]
Shouldn't it define a size of -1 ???? How comes it can work ? I guess it's not a mistake since you can find this in all STM32 startup codes ^^
Thanks,
Upvotes: 1
Views: 643
Reputation: 67476
The answer is very simple. .
(dot) means current address. So the expression (from the github)
.size Reset_Handler, .-Reset_Handler
sets the size of the section Reset_Handler to the current address minus beginng of the section.
Upvotes: -1