Google
 
   
Login
Username:

Password:


Lost Password?

Register now!
Search
Main Menu
top books
Polls
What do you think about php-deluxe.net?
Excellent!
Cool
Hmm..not bad
What the hell is this?
encyclopedia
recommendation
compare webbrowser
Freenet DSL
Who's Online
5 user(s) are online (5 user(s) are browsing encyclopedia)

Members: 0
Guests: 5

more...
browser tip
Unix Befehle
manual of unix befehle
recommendation!
Sponsored
partner

Linker

In computer science, a linker or link editor is a computer program that takes one or more object code generated by Compilers 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 (computing) is often used as a synonym for linker, blurring the distinction between the compile-time process and the run-time process. Although these processes are somewhat similar, this article will still use linking for the former and loading for the latter.)

The objects are program modules containing machine code and information for the linker. This information comes mainly in the form of symbol definitions, which come in two varieties:

  • Defined or exported symbols are function (programming)s or Variables that are present in the module represented by the object, and which should be available for use by other modules.
  • Undefined or imported symbols are functions or variables that are called or referenced by this object, but not internally defined.
  • In a nutshell, the linker s job is to resolve references to undefined symbols by finding out which other object defines a symbol in question, and replacing placeholders with the symbol s address.

    Linkers can take objects from a collection called a library (computer science) . The advantage of such a collection over a single big object is that the final program does not include the whole library, only those objects from it that are needed (define relevant symbols). Libraries for diverse purposes exist, 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). On computer hardware offering virtual memory this is usually omitted, though—every program is put into its own address space, so there is no conflict even if all programs load at the same base address.

    =Dynamic Linking=

    Modern operating system environments allow library (computer science)#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 immediately benefit from the correction. Programs that included this function by static linking would have to be re-linked first.
  • == Criticism ==

    Dynamic linking is often portrayed as universally good, but it has several drawbacks that aren t immediately apparent. Because dynamic linking inherently involves modification of the executable code, it is counter to the principles of virtual memory which is most efficient when each page of the executable image appears the same on disk as in memory, and is unmodified in use. This allows a virtual memory operating system to page parts of the image in and out of main memory at will. The common workarounds for this problem have issues of their own. If the image is copied to a new, modified image via copy on write , then the modified image takes up new disk space. Also, since it is modified, it cannot be shared between different invocations of the same program in memory (part of the abilities of a computer multitasking operating system). Windows uses a method where each linkage is double indirect via a special linkage page in the lower part of an .exe image. This allows the main code pages to stay the same, and only this linkage directory is changed. However, this adds overhead to every call in the program to other modules or the operating system.

    Second, dynamic linking means that the final working image of the program will be made up of different modules that may be united together only in the users system. This occurs because each user may have slightly different versions of each dynamically linked module, leading to an exponential number of combinations. Thus, the actual program code run may exist in that exact form only on one user s system. This can lead to odd bugs, and increases testing problems for vendors. As a result, there has been a movement to static link modules to programs and eliminate dynamic link modules, even where that capability exists in the operating system.

    =See also=

  • Library (computer science)
  • Name decoration
  • Relocation table
  • =References=

    *John R. Levine: Linkers and Loaders , Morgan-Kauffman, ISBN 1-55860-496-0