symbol relocation during dynamic loading
Ian Lance Taylor
ian@wasabisystems.com
Mon Apr 19 20:45:00 GMT 2004
Robert Schweikert <Robert.Schweikert@abaqus.com> writes:
> I am using the --retain-symbols-file <filename> link option to restrict
> the exported symbols from shared libraries. Using elfdump libName
> --export to compare the exported symbols between libraries linked with
> and without the --retain-symbols-file <filename> option indicates that
> things worked as expected and I only get the symbols I want exported.
> Also the size of the "restricted" library is smaller (as expected).
>
> The question now is why the relocations are the same between the 2
> libraries. If I set the LD_DEBUG environment variable to statistics and
> load both libraries I end up with the same number of relocations. My
> expectation was that the number of relocations would decrease and thus I
> would end up with faster load times.
>
> Can anyone explain why the number of relocations did not show any
> changes?
Hmmm. You neglected to mention your target. The only type of
relocation which is likely to disappear entirely is a PC relative
relocation to a publically visible function. If the function is
hidden, then the relocation can go away. All other relocations are
likely to remain, perhaps in the form of R_*_RELATIVE.
That said, there is another way to hide symbols in a shared library,
which is to use a version script. It is possible that using a version
script will remove relocations where --retain-symbols-file will not.
That is because the implementation of the two options is, I believe,
different. I haven't checked whether this is so. But it is possible.
(Yes, if they are indeed different, this probably a bug.)
Ian
More information about the Binutils
mailing list