Using the stack from inline assembly

Jeff Law law@redhat.com
Tue Dec 13 15:41:00 GMT 2016


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.

The key thing to keep in mind is that GCC does not parse the instruction 
for this kind of thing.  Think of it as a textual blob.  GCC instead 
relies on the inputs/outputs/clobbers lists to build proper dataflow 
graphs.  Get the inputs/outputs/clobbers right and it should work fine.


>
> Will GCC automatically disable use of the red zone on x86_64 if inline
> assembly is used, or at least assume it's clobbered by inline assembly?
> If not, how is this supposed to work if it does at all?
I do not think the use of inline assembler disables the red zone on the 
x86.

Jeff



More information about the Gcc-help mailing list