LD is the GNU Linker, sometimes also referred to as gld or ld.bfd. It is designed to combine object files and libraries into executables and shared libraries. It is part of the GNU Binutils project.

LD is often invoked directly by the GCC compiler, so many users are unaware of its existence.

LD is not necessarily the fastest linker. (..., but is certainly seeing occasional performance improvement work.) Its primary goals include supporting a diverse set of architectures and file formats, and to provide a lot of features. If linking speed is more important, then another linker, such as gold, lld, or mold should be considered, too.

LD is a static linker which means that it runs when a application or shared library is being built. It is not the same as a dynamic linker which runs when an application starts. LD creates binary files which can be run, a dynamic linker (often called ld.so) takes these run-able files and actually starts them executing.

LD is controlled via its command line and special script files. The script files tell the linker how to lay out an application in memory and the command line tells the linker which files to combine and what non-default things it should do.

Here is a simple example of an LD command line:

 ld foo.o bar.o -o prog 

This combines two input object files foo.o and bar.o into an output file called prog. No linker script has been specified, so LD will uses its own, built-in internal script.

None: ld (last edited 2023-09-26 16:45:33 by tschwinge)

All content (C) 2008 Free Software Foundation. For terms of use, redistribution, and modification, please see the WikiLicense page.