Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/asm, runtime: textflag for CABI #21004
The runtime assembly code includes many functions that are called from outside the runtime and are called with the C ABI. This means the functions first have to save callee-saved registers manually.
For example, see runtime·sigtramp in sys_linux_*.s.
Once after diagnosing a callee-save error, I failed to save all the callee-save registers. This meant months later, @aclements had to go through the same long debugging session. We could make this more robust (and potentially make our assembly a bit easier to read) by adding a CABI text flag, and have the assembler insert code for saving and restoring registers.
I think we would want the flag to automatically reserve space for them, just like we do for the frame pointer on x86 and the saved LR on LR machines.
Would this flag save all of the callee-save registers? That's potentially a lot of registers that aren't actually going to be clobbered. Where these bugs are really insidious are the C callee-save registers that are used implicitly by obj (so they never explicitly appear in the assembly).
The cases that I can think of are not hot functions, so I would be happy saving all callee-save registers. Though I agree just the invisible obj registers would be enough to let me breath easy.
As to where, reserved stack space. These are functions called from C, so there's stack to use.