James Kehl pisze:
The quad-alignment was what I was thinking about. According to ARM AAPCS: "5.2.1.2 Stack constraints at a public interface The stack must also conform to the following constraint at a public interface: SP mod 8 = 0. The stack must be double-word aligned." It seems a little odd that sprint would *fail* when the stack was more highly aligned; is your startup code perhaps pushing an odd number of words onto the stack, or am I maybe getting confused about the Full-Descending addressing?
OK - aligning the stack to 8bytes fixed the issue. It must have been too late the last time I tried to find the solution (;
I take back what I've written about -nostartfiles and --gc-sections. Still sprintf() needs a lot of stack though - about 700B!
Funnily enough, the way I read the AAPCS, the first argument to sprintf should be in R2:R3, and not on the stack...!
Compiler takes care of this and indeed it's true - variadic functions fill the four lower registers with parameters first, then the stack.
4\/3!!