Hi,
I am trying to compile OpenSLP
(http://openslp.svn.sourceforge.net/viewvc/openslp/trunk/openslp/common/)
on Solaris Sparc 9 using gcc 3.4.6 and the Solaris ld. OpenSLP has some
common code that gets compiled into a library (.a file) which then gets
included into a shared object and a executable. When compiling the
shared object I get the following errors:
Text relocation remains referenced
against symbol offset in file
sparc_atomic_add_32 0x14
../common/.libs/libcommonlibslp.
a(slp_atomic.o)
sparc_atomic_xchg_32 0x44
../common/.libs/libcommonlibslp.
a(slp_atomic.o)
ld: fatal: relocations remain against allocatable but non-writable sections
collect2: ld returned 1 exit status
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?
Thanks in advance
-Jim
int32_t sparc_atomic_add_32(volatile int32_t * p, int32_t i);
int32_t sparc_atomic_xchg_32(volatile int32_t * p, int32_t i);
void sparc_asm_code(void)
{
asm( ".align 8");
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");
asm( " nop");
asm( " add %l2, %o1, %o0");
asm( " membar #LoadLoad | #LoadStore | #StoreStore | #StoreLoad");
asm( "retl");
asm( "nop");
asm( ".align 8");
asm( ".global sparc_atomic_xchg_32");
asm( ".type sparc_atomic_xchg_32, #function");
asm( "sparc_atomic_xchg_32:");
asm( " membar #LoadLoad | #LoadStore | #StoreStore | #StoreLoad");
asm( " ld [%o0], %l0");
asm( " mov %o1, %l1");
asm( " cas [%o0], %l0, %l1");
asm( " cmp %l0, %l1");
asm( " bne sparc_atomic_xchg_32");
asm( " nop");
asm( " mov %l0, %o0");
asm( " membar #LoadLoad | #LoadStore | #StoreStore | #StoreLoad");
asm( "retl");
asm( "nop");
}