On 05/02/2018 12:57 AM, Thomas Preudhomme wrote: > Hi Segher, > > As mentionned in the ticket this was my first thought but this means > making the pattern aware of all the possible way the address could be > access (PIC Vs non-PIC, Arm Vs Thumb-2 Vs Thumb-1) to decide how many > scratch registers are needed. I'd rather reuse the existing pattern as > much as possible to make sure they are well tested. Ideally I wanted a > way to mark a REG RTX so that it is never spilled and such that the > mark is propagated when the register is moved to another register or > propagated. But that is a bigger change so decided it should be an > improvement for later but needed another solution right now. > > By the way about making sure the address is not left in a register, I > have a question regarding the current stack_protect_set and > stack_protect_check pattern and their requirements to have register > cleared afterwards: why is that necessary? Currently not all registers > are cleared and the guard is available in the canari before it is > overwritten anyway so I don't see how clearing the register adds any > extra security. What sort of attack is it protecting against? I'm not aware of any way to make a REG so that it's never spilled. It's a concept we simply don't have.
About the closest you get is a fixed register. But you certainly don't want to do that. I really think you're going to have to address this primarily in the ARM backend, probably making a fair amount of things opaque to the rest of the compiler. Jeff