Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does code pattern like .size X,.-X do?

My question is about some popular but not well documented code I have found in ARM CORTEX M startup files like this STM32.

The 'pattern' is:

.size X,.-X

,where X is a symbol or label.

I have found this answer and understand how .size directive and dot special symbol work, but still complete line seems to do nothing to me. The result of the operation .-X isn't stored anywhere.

Could anybody explain what the line does?

like image 920
FemtoFarad Avatar asked Oct 15 '18 13:10

FemtoFarad


1 Answers

That is placed at the end of function X, and the size of the function is the difference between the end of the function and the beginning. . is the current location so it's saying .size x is the difference between here and the label x.

like image 97
Colin Avatar answered Oct 03 '22 00:10

Colin