[uClibc] Re: Use GCC option -fPIC for shared objects

Benjamin ZORES Benjamin.Zores at sxb.bsf.alcatel.fr
Fri Apr 30 07:22:00 UTC 2004


Peter S. Mazinger wrote:

> Check your file w/ readelf -d cpu.so | grep TEXTREL, if you have TEXTREL, 
> that is the problem, it is not enough to use -fPIC for cpu.so only, you 
> have to build all the objects included into cpu.so w/ -fPIC, than TEXTREL  
> should dissapear, if not then some code is not PIC aware, (for ex.  
> assembler code), some older code needs -DPIC too, check code for #ifdef 
> PIC and change it to __PIC__)

thx for the quick answer.
indeed, you're right, i've got reference to TEXTREL.

my problem is that my cpu.so lib is build, including only a unique file :

CFLAGS=-Os -Wall -fPIC
LD_FLAGS=-Wl,-shared,-Bsymbolic,--dynamic-linker,/lib/ld-uClibc.so.0,-soname,
LD_LIB=-lz -s

cpu.o:	cpu.c
	${CC} ${CFLAGS} -DPIC -c cpu.c

cpu.so:	cpu.o
	${CC} ${CFLAGS} ${LD_FLAGS}cpu.so ${LD_LIB} -B./ cpu.o -o cpu.so


So, i've no other file to compile using -fPIC flag I think.

Besides, my cpu.c file is quite simple, with no asm code.
Only a call to a function defined in another .o file (which has also 
been compiled using -fPIC) but which is not linked at compilation time.

Hope it can help,

Best regards

Benjamin Zores






More information about the uClibc mailing list