简体   繁体   中英

.size operator in assembly ( stm32 )

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,

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM