Using the stack from inline assembly

Segher Boessenkool segher@kernel.crashing.org
Tue Dec 13 18:16:00 GMT 2016


On Tue, Dec 13, 2016 at 04:51:34PM +0100, Florian Weimer wrote:
> On 12/13/2016 04:41 PM, Jeff Law wrote:
> >On 12/13/2016 12:13 AM, Florian Weimer wrote:
> >>Is it possible to use the stack from inline assembly?  I'm particularly
> >>interested in i386 and x86_64, and push/pop instructions and function
> >>calls.
> >You can push/pop and perform a function call.  Obviously you have to
> >express what's going on from a dataflow standpoint if you use a new
> >style asm -- that includes notifying GCC of the registers clobbered at
> >the call point and the memory usage.
> 
> How do I express that?  It's not that %rsp is clobbered, its unchanged. 
> How can I express a clobber on memory which does not even have an 
> address as far as C is concerned?

Clobbering "memory" does not work here.  Clobbering "rsp" however seems
to work.  But, "seems to", I don't think there is a guarantee anywhere.
Clobbering the stack pointer forces the use of the frame pointer, but is
that guaranteed even?


Segher



More information about the Gcc-help mailing list