This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Using the asm suffix


On Sun, Aug 16, 2015 at 06:33:40PM -0700, David Wohlferd wrote:
> As a followup to my update to the inline asm docs, I'm cleaning up the 
> docs for 'Asm Labels.'  The changes I want to make are pretty 
> straight-forward (attached; comments welcome).  But then I came across 
> this line of code (from 
> https://github.com/rschmukler/cs537-p5/blob/master/xv6/proc.h#L38):
> 
>     extern struct proc *proc asm("%gs:4");
> 
> This x86 code says that 'proc' is located at an offset of 4 bytes from 
> the gs register.

It says that the assembler name of the function is "%gs:4"; it works
by accident, not by design (imagine what would happen if the function
was defined in this same translation unit!)

> There isn't any description of using asm like this in the current Asm 
> Labels docs.

And there shouldn't be.  It's a hack.


Segher


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]