This is the mail archive of the
mailing list for the GCC project.
Re: Using the asm suffix
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: David Wohlferd <dw at LimeGreenSocks dot com>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>, Sandra Loosemore <sandra at codesourcery dot com>
- Date: Mon, 17 Aug 2015 05:24:17 -0500
- Subject: Re: Using the asm suffix
- Authentication-results: sourceware.org; auth=none
- References: <55D139F4 dot 7060109 at LimeGreenSocks dot com>
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
> 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.