This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: inline assembly as PIC code?
- From: Ian Lance Taylor <iant at google dot com>
- To: Jim Marshall <jim dot marshall at wbemsolutions dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: 25 Jan 2008 18:46:47 -0800
- Subject: Re: inline assembly as PIC code?
- References: <fne0e5$hfp$1@ger.gmane.org>
Jim Marshall <jim.marshall@wbemsolutions.com> writes:
> Both of these functions are declared with inline assembly (see
> below). When I force the compiler to use the GNU ld it compiles fine
> with out error. I was wondering if anyone here could tell me if there
> is a way to make the compiler generate PIC code for the asm, or is
> this something that has to be done to the asm code for that?
> asm( ".global sparc_atomic_add_32");
> asm( ".type sparc_atomic_add_32, #function");
> asm( "sparc_atomic_add_32:");
> asm( " membar #LoadLoad | #LoadStore | #StoreStore | #StoreLoad");
> asm( " ld [%o0], %l0");
> asm( " add %l0, %o1, %l2");
> asm( " cas [%o0], %l0, %l2");
> asm( " cmp %l0, %l2");
> asm( " bne sparc_atomic_add_32");
Instead of branching to a global symbol, branch to a local one.
E.g. put a local label after the global one, and use that as the
branch target.
Ian