Is there a way for the assembler (or a static analyzer) to warn if the hand-coded assembly code contains violations of the platform's assembly calling convention?
The platform I'm using is ARMv7A with the GNU GAS assembler. The reason for the question is a bug I wrote where my function did not push/pop the required registers (r4-r11 on ARM) upun entry/exit. The registers were trashed, causing the caller to crash (thankfully, the automated tests detectected the bug). Simplified program:
my_function:
mov r4, #42 @Trash register r4 in violation of calling convention
bx lr @Return from function
caller:
...
mov r4, #4 @Initialise register r4, to be used later
bl my_function @Call my_function with no arguments
mov r0, r4 @Set argument r0 as r4 (== 42, but should be 4)
bl other_function @Call other_function with (the now trashed) argument r0
ARM calling convention: http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042d/IHI0042D_aapcs.pdf