In computer science, a linker or link editor is a program that takes one ormore objects generated by a compiler and assembles them into a single executable program.

In IBM mainframe environments such as OS/360 this program is known as a "linkage editor".

On Unix variants the term loader is often used as a synonym for linker. Because this usage blurs the distinction between the compile-time process and the run-time process, this article will use "linking" for the former and "loading" for the latter. However, in some operating systems the same program handles both the jobs of linking and loading a program; see "dynamic linking".

Computer programs are typically comprised of several parts or modules; these parts, if not all contained within a single object file, refer to each other by means of symbols. Typically, an object file can contain three kinds of symbols:

* defined symbols, which allow it to be called by other modules,
* undefined symbols, which call the other modules where these symbols are defined, and
* local symbols, used internally within the object file to facilitate relocation.

When a program comprises multiple object files, the linker combines these files into a unified executable program, resolving the symbols as it goes along.

Linkers can take objects from a collection called a "library". Some linkers do not include the whole library in the output; they only include its symbols that are referenced from other object files or libraries. Libraries exist for diverse purposes, and one or more system libraries are usually linked in by default.

The linker also takes care of arranging the objects in a program's address space. This may involve "relocating" code that assumes a specific base address to another base. Since a compiler seldom knows where an object will reside, it often assumes a fixed base location (for example, zero). Relocating machine code may involve re-targeting of absolute jumps, loads and stores.

The executable output by the linker may need another relocation pass when it is finally loaded into memory (just before execution). This pass is usually omitted on hardware offering virtual memory — every program is put into its own address space, so there is no conflict even if all programs load at the same base address.This pass may also be omitted if the executable is a position independent executable.

Dynamic linking

Modern operating system environments allow "dynamic linking", that is the postponing of the resolving of some undefined symbols until a program is run. That means that the executable still contains undefined symbols, plus a list of objects or libraries that will provide definitions for these. Loading the program will load these objects/libraries as well, and perform a final linking.

This approach offers two advantages:
* Often-used libraries (for example the standard system libraries) need to be stored in only one location, not duplicated in every single binary.
* If an error in a library function is corrected by replacing the library, all programs using it dynamically will benefit from the correction after restarting them. Programs that included this function by static linking would have to be re-linked first.


As the compiler has no information on the layout of objects in the final output, it cannot take advantage of shorter or more efficient instructions that place a requirement on the address of another object. For example, a jump instruction can reference an absolute address or an offset from the current location, and the offset could be expressed with different lengths depending on the distance to the target. By generating the most conservative instruction (usually the largest relative or absolute variant, depending on platform) and adding "relaxation" hints, it is possible to substitute shorter or more efficient instructions during the final link. This step can be performed only after all input objects have been read and assigned temporary addresses; the relaxation pass subsequently re-assigns addresses, which may in turn allow more relaxations to occur. In general, the substituted sequences are shorter, which allows this process to always converge on the best solution given a fixed order of objects; if this is not the case, relaxations can conflict, and the linker needs to weigh the advantages of either option.


*David William Barron, "Assemblers and Loaders". 1972, Elsevier.
*C. W. Fraser and D. R. Hanson, "A Machine Independent Linker". Software-Practice and Experience 12, 4 (April 1982).
*IBM Corporation, "Operating System 360, Linkage Editor, Program Logic Manual", 1967 []
*D.W. Jones, "Assembly Language as Object Code". Software-Practice and Experience 13, 8 (August 1983)
*John R. Levine: "Linkers and Loaders", Morgan-Kauffman, ISBN 1-55860-496-0
*Leon Presser, John R. White: "Linkers and Loaders". ACM Computing Surveys, Volume 4, Number 3, September 1972, pp.149-167 []
*Norman Ramsey, "Relocating Machine Instructions by Currying". (1996) []
*David Salomon, "Assemblers and Loaders". 1993 []

ee also

*Dynamic library
*GNU linker
*Name decoration
*Object file
*Relocation table
*Static library

External links

* [ Linkers and Loaders by Sandeep Grover]
* [ Another Listing of Where to Get a Complete Collection of Free Tools for Assembly Language Development]
* [ GoLink: a free linker for Windows programming]

Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • linker — linker …   Deutsch Wörterbuch

  • Linker — steht für: Linker (Computerprogramm), ein Computerprogramm, das einzelne Programmmodule zu einem ausführbaren Programm zusammenstellt eine inflationsindexierte Anleihe, siehe Inflation Linked Bond ein Mitglied der politischen Linken, siehe… …   Deutsch Wikipedia

  • linker — linker. См. линкер. (Источник: «Англо русский толковый словарь генетических терминов». Арефьев В.А., Лисовенко Л.А., Москва: Изд во ВНИРО, 1995 г.) …   Молекулярная биология и генетика. Толковый словарь.

  • Linker — Linker, s. Lyncker …   Pierer's Universal-Lexikon

  • Linker — Linker, Teil eines ⇒ Nucleosoms …   Deutsch wörterbuch der biologie

  • linker — lịn|ke(r, s) 〈Adj.〉 auf der Seite befindlich, auf der (nach dem Volksmund) das Herz liegt; Ggs rechte(r, s) ● der linker Arm, das linker Bein; linkerr Hand links, linkerseits; Ggs rechter Hand; linker Masche M., in die mit der Nadel von hinten… …   Universal-Lexikon

  • Linker DS — Un linker DS est un outil servant à jouer, regarder une vidéo, écouter de la musique... sur une Nintendo DS, Nintendo DS Lite ou Nintendo DSi. Certains linkers sont compatibles Nintendo DS, d autres Nintendo DS et Nintendo DS Lite ou d autres… …   Wikipédia en Français

  • Linker — Lịn|ke(r) 〈f. 30 (m. 29)〉 jmd., der Linksparteien nahesteht Lịn|ker 〈m. 3; EDV〉 Programm, das einzelne Subprogramme od. mehrere kompatible Einzelprogramme zu einer Gesamtanwendung zusammenfasst [→ Link] * * * Lịn|ker [engl. link = Bindeglied;… …   Universal-Lexikon

  • Linker — Édition de liens Pour les articles homonymes, voir Lien. Lors d’un développement informatique, l’édition des liens est un processus qui permet de créer des fichiers exécutables ou des bibliothèques dynamiques ou statiques, à partir de fichiers… …   Wikipédia en Français

  • linker — {{#}}{{LM L42819}}{{〓}} {{[}}linker{{]}} {{■}}(ing.){{□}} {{《}}▍ s.m.{{》}} Programa informático que traduce un idioma computacional a otro. {{★}}{{\}}PRONUNCIACIÓN:{{/}} [línker]. {{★}}{{\}}ORTOGRAFÍA:{{/}} Por ser un extranjerismo debe… …   Diccionario de uso del español actual con sinónimos y antónimos

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”