Shared libraries: Avoiding lazy procedure linkage

Ramana Radhakrishnan
Tue Nov 16 12:44:00 GMT 2004

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 
( 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 :


More information about the Gcc-help mailing list