This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Shared libraries: Avoiding lazy procedure linkage
- From: Ramana Radhakrishnan <ramana dot radhakrishnan at codito dot com>
- To: Tushar <tusharpadlikar at yahoo dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 16 Nov 2004 18:13:40 +0530
- Subject: Re: Shared libraries: Avoiding lazy procedure linkage
- References: <20041116122022.90552.qmail@web50505.mail.yahoo.com>
Tushar wrote:
Hello,
I've used gcc 3.4.1 and gcc 2.95.3 (This is actually
arm-linux-gcc)for creating shared libraries. There is
a difference in the way these two tool chains generate
libraries.
In case of 3.4.1 the generated code uses lazy
proceprocedure linkage (uses .plt .got route ) in
shared libraries. In case of 2.95.3..... it doesnt do
this. The compilation/linking options remaining the
same.
Whether you are using 2.95 or 3.4.1, dynamic linking would always
require the use of the PLT and the GOT on ELF / GNU Linux systems.
Lazy dynamic linking has nothing to do with the versions you are using.
Lazy dynamic linking is actually a job of the dynamic linker / loader
(ld-linux.so.2 usually on linux systems) and is controlled by the
environment variable LD_BIND_NOW or the linker option -z now. This can
be passed to the linker using the -Wl option with gcc. Lazy dynamic
linking controls whether resolution of function references need to be
done at load time or lazily whenever the function is referenced.
My question is...if its possible to avoid this lazy
procedure linkage in case of 3.4.1 using some command
line option. (which is seemingly default in 2.95.3)
You might like to read Chapters 8-10 in the book by John Levine on
Linkers and Loaders where he explains how the PLT and the GOT work . You
might also like to read Ulrich Dreppers paper on how shared libraries
work at : http://people.redhat.com/drepper/dsohowto.pdf
cheers
Ramana