This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Force usage of PLT (on powerpc)?


Is there any way to compile code such that the weak and unknown symbols are routed through the procedure linkage table (PLT) without requiring the global offset table (GOT) that -fPIC brings?

A little background on our situation . . .

We have an embedded device running Linux that currently has one monolithic application that can talk to many different hardware devices.  As memory is a concern, we would like to instead load the hardware support via shared modules.  While runtime performance is also a key concern, we are not as worried about start up time, since our device will be running for months at a time.

Everywhere that talks about shared libraries always says to use -fPIC.  Taking a look at the pros/cons of -fPIC:

-fPIC pros:
1) allows shared libraries to be shared in memory by multiple applications
2) tells the compiler not to use some symbol lookup optimizations

-fPIC cons:
1) access to all methods goes through the Global Offset Table (GOT)
2) access to all global data goes through the GOT as well

However for our particular application it did not seem to be worthwhile.  We only have one process running that will be loading the shared libraries, and the extra overhead of the GOT is significant.  With -fPIC usage, we have seen a 15% degradation in performance.  I have made some trivial test cases (a method call that simply returns a global variable) that has shown as much as 4x run time when -fPIC is set!

I tried compiling our shared libraries without -fPIC and it works fine on an x86.  We took a small hit relocating the shared libraries when they were loaded, but after that our performance is comparable to code linked into the application.  All seemed good.

On the powerpc however, I started running into problems with the 32MB limit for REL24 jumps.  While the application could call any method in the shared library, I ran into two problem areas in the library.  Any undefined symbols and any weak symbols (common in c++ code) were compiling with REL24 relocations, which may or may not reach since they are limited to 32MB.

I have also tried compiling with -mlongcall.  While that did work, it unfortunately significantly increased the size of our applications...  Is there any way to specify that only weak and undefined symbols should use long calls?  Since some of the weak symbols are compiler generated, I can't just add the gcc specific longcall attribute to those methods.

Thank you,

Chris Kirby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]