[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: compiling



On Mon, 30 Oct 2000, Kerstin Hoef-Emden wrote:

> What is the difference between ld and ldd (I read that ldd is the
> dynamic linker, but why are two linkers necessary?)

I think you're thinking of ld-linux.so (dynamic
linker). Basically, it handles, in simple terms, runtime linking
to shared libs.  When you compile a shared binary, it most likely uses
functions from other libs (printf(), et.al).  What ld-linux.so does is try
to load those functions from the other libs that the shared binary is
linked to.  This is opposed to compiling a static binary, which directly
includes the functions in the binary itself (meaning larger binaries, but
they do not rely on other libs).

To summarise ld, I must quote the docs since they really do describe it
best:

   `ld' combines a number of object and archive files, relocates their
data and ties up symbol references. Usually the last step in compiling
a program is to run `ld'.

Basically, ld actually massages the object files (.o) into an executable
binary.  This process can include making sure that the binary's external
symbol locations can be resolved (and where to find them) in the case of
shared binaries, or actually including the external functions in the final
binary in the case of static binaries.  If you want some good ld info,
check the texinfo docs ('info ld').  I don't mean to sound like I'm saying
"RTFM" in a negative way, but it really does summarise ld better than I
could.

> What does this error message mean (what is this linker script file?):

Linker scripts basically describe how to perform the linking process to
ld.  Here's another quote from the ld docs:

   The main purpose of the linker script is to describe how the
sections in the input files should be mapped into the output file, and
to control the memory layout of the output file.  Most linker scripts
do nothing more than this.  However, when necessary, the linker script
can also direct the linker to perform many other operations, using the
commands described below.

Linker scripts are VITAL to the operation of the linker.  Many of us have
some custom linker scripts laying around for various specialised
tasks.  On Alpha, the most common and well-known is the one that is used
when -taso is passed to ld (reorients the resulting binary to a 32-bit
space).  If ld is claiming that it can't find the script, you may want to
check /usr/lib/ldscripts to see if you can find the script name somewhere
in there.  The default binutils installation on Alpha should have
these files in /usr/lib/ldscripts:
alpha.x
alpha.xn
alpha.xu
elf64alpha.xbn
elf64alpha.xr
elf64alpha.xu
alpha.xbn
alpha.xr
elf64alpha.x
elf64alpha.xn
elf64alpha.xs

If you have any more questions about binutils, let me know (I'm the
binutils maintainer for Debian, fyi, and have been working on the Alpha
port for years now).

C



Reply to: