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: Prelinking relative relocations in shared objects


Ian Lance Taylor <ian@airs.com> writes:

> If I understand you, you are building a shared library, and you are
> compiling without -fPIC, and you want to reduce the number of runtime
> relocations, and you see a lot of PC relative relocations in your
> shared library which refer to symbols defined within your shared
> library.  Since they are PC relative, it should be possible to not
> generate a PC relative relocation, but simply resolve the relocation.

Exactly.

> The relocations probably exist because the ELF linking rules permit
> overriding a symbol in a shared library.  Therefore, all references to
> global symbols from a shared library require a relocation, whether the
> symbol is defined in the same shared library or not.

Yes, I know. However this shared library almost only contains one big object
that is linked using -r from multiple objects and thus such rules do not apply.

> You can stop this by using -Bsymbolic, which tells the linker that all
> references to symbols defined in the same shared library are to be
> resolved locally.

As I wrote in my original mail (I probably wasn't very clear), I tried
this but it doesn't seem to make any difference for my linker (which
is collect2 inside gcc 2.25). Should I try newer versions?

To me it seems as if -Bsymbolic only sets a flag that makes the
runtime linker behave differently.

Jan


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