Problem creating PIC executable

Ian Lance Taylor iant@google.com
Mon Feb 21 20:39:00 GMT 2011


Stefano Bonifazi <stefboombastic@gmail.com> writes:

> Are you the same author of this great blog
> http://www.airs.com/blog/archives/category/programming/page/21 ?

Yes.

> I have tried the following command:
>
>> "readelf -d myobjectfile | fgrep TEXT"
>
>
> to all object files opened here:
> http://cid-9d0dd0f6c6e22fe8.office.live.com/self.aspx/Documenti/ppc-test.linking.txt
> but I could not see anything.. all seemed to be PIC .. I dunno if
> there is any other way for checking if an object file or shared file
> is really PIC

When linking with -fPIC I would normally expect the gcc driver to use
crtbeginS.o rather than crtbegin.o.  See if crtbegin.o in particular was
compiled without -fPIC.

> the same command on the final executable gives:
>
>> 0x00000016 (TEXTREL)   0x0

It may help to see what relocations are in the text or data segments, to
see why the TEXTREL entry is being added.

Ian



More information about the Gcc-help mailing list