This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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]

Re: Eliminating PLT calls during linking


On Wed, Nov 27, 2002 at 08:53:07PM +0300, Leonid Romanov wrote:
> Hi!
> I'm a little bit tired from reading ELF spec, so please excuse me if my
> question is dumb or doesn't belong there.
> Let's suppose I have two static I386 libraries compiled with -fpic
> option, lib1 and lib2. lib1 has global foo() function which calls extern
> bar() function, and lib2 has that bar() function. Because of PIC code,
> bar() function in lib1 is called via PLT.
> Now, I want to link these two libraries together to produce shared
> library from which I'm going to use only foo() function. But my problem
> is that in resulting shared library bar() function is still called via
> PLT. And I want it to be called via offset from PC, or GOT, or whatever.
> The reason is size. Eliminating PLT entry for bar() will allow me to
> delete its symbol from symbols table, and I have lot of such bar()
> functions in my real libraries (which are C++ methods with long mangled
> names).
> Is it possible? If so, could you point me to right direction? Should I
> look at ld options, or ld scripts, or some object files hacking is
> required? 

Since bar () is global, it has to be called via PLT. Otherwise, you
can't override bar (). However, if you make bar () "local" to the
shared library, you may get what you wanted. There are several ways
to do it:

1. -Bsymbolic. It has some side effects.
2. Make bar hidden. Use a separate asm file:

	.hidden bar

3. Make bar local using symbol versioning script:

{
local:
  bar; 
};


H.J.


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