1752783 Members
6079 Online
108789 Solutions
New Discussion юеВ

shared objects

 
lara
Advisor

shared objects

Hi,

Is there a way to find whether an object(.o file ) is compiled with -pic or not.

Regards,
Lara
5 REPLIES 5
Stuart Browne
Honored Contributor

Re: shared objects

Not 100% sure I'm afriad, but by doing some tests locally, using '-fPIC' (as '-pic' using a modern gcc doesn't work), with the tool 'readelf', a -fPIC binary has references to "_GLOBAL_OFFSET_TABLE_", where as an object compiled without -fPIC doesn't..

I've not done enough programming to actually know what '-pic' or '-fPIC' are supposed to do..
One long-haired git at your service...
lara
Advisor

Re: shared objects

Seems to be not neccessarly true. Anyway thanks for your suggestion.

Lara
lara
Advisor

Re: shared objects

Seems to be not necessarly true. Anyway thanks for your suggestion.

Lara
Umapathy S
Honored Contributor

Re: shared objects

Lara,
I dont have a linux box nearby to test it. But in hpux the file command gives out "relocatable" for position independent code. As you might be aware for the shared libs you need to have PIC.
Just compile a c file both ways and test it on the box.

HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
lara
Advisor

Re: shared objects

Umapathy,

relocatable need not necessarly mean the object file has position independent code.

Lara