Content deleted Content added
Undid revision 1107808339 by 2804:7F0:B1C0:9E07:B8F3:84DC:3C5D:AB05 (talk) |
HeyElliott (talk | contribs) ce |
||
(48 intermediate revisions by 30 users not shown) | |||
Line 1:
{{Short description|
{{Use dmy dates|date=January 2020|cs1-dates=y}}
[[File:Linker.svg|thumb|An illustration of the linking process. Object files and [[static library|static libraries]] are assembled into a new library or executable]]
A simpler version that writes its [[Input/output|output]] directly to [[Computer memory|memory]] is called the ''loader'', though [[loader (computing)|loading]] is typically considered a separate process.<ref name="IBM_1972"/><ref name="Barron_1978_Consolidator"/>
== Overview ==
Computer programs typically are composed of several parts or modules; these parts/modules do not need to be contained within a single [[object file]], and in such cases refer to each other
While the process of linking is meant to ultimately combine these independent parts, there are many good reasons to develop those separately at the [[Source code|source]]-level. Among these reasons are the ease of organizing several smaller pieces over a [[Monolithic codebase|monolithic]] whole and the ability to better define the purpose and responsibilities of each individual piece, which is essential for managing complexity and increasing long-term maintainability in [[software architecture]].
Typically, an object file can contain three kinds of symbols:
* defined "external" symbols, sometimes called "public" or "entry" symbols, which allow it to be called by other modules,
Line 16 ⟶ 20:
For most compilers, each object file is the result of compiling one input source code file. 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
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]] into another base. Since a compiler seldom knows where an object will reside, it often assumes a fixed base ___location (for example, [[zero base|zero]]). Relocating machine code may involve re-targeting
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 [[computer hardware|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 ==
Line 36 ⟶ 40:
There are also disadvantages:
* Known on the [[Windows]] platform as "[[DLL hell]]", an incompatible updated library will break executables that depended on the behavior of the previous version of the library if the newer version is
* A program, together with the libraries it uses, might be certified (e.g. as to correctness, documentation requirements, or performance) as a package, but not if components can be replaced (this also argues against automatic OS updates in critical systems; in both cases, the OS and libraries form part of a ''qualified'' environment).
[[Containerization (computing)|Contained]] or [[OS-level virtualization|virtual]] environments may further allow [[System administrator|system administrators]] to mitigate or trade-off these individual pros and cons.
Line 49 ⟶ 53:
== {{anchor|Consolidator}}Linkage editor ==
In IBM [[System/360]] through [[IBM Z]] [[Mainframe computer|mainframe]]
One advantage of this is that it allows a program to be maintained without having to keep all of the intermediate object files, or without having to re-compile program sections that haven't changed. It also permits program updates to be distributed in the form of small files (originally [[card deck (computing)|card deck]]s), containing only the object module to be replaced. In such systems, object code is in the form and format of 80-byte punched-card images, so that updates can be introduced into a system using that medium. In later releases of OS/360 and in subsequent systems, load-modules contain additional data about versions of components modules, to create a traceable record of updates. It also allows one to add, change, or remove an [[overlay (programming)|overlay]] structure from an already linked load module.
The term "linkage editor" should not be construed as implying that the program operates in a user-interactive mode like a text editor. It is intended for batch-mode execution, with the editing commands being supplied by the user in sequentially organized files, such as [[punched card]]s, [[direct-access storage device|DASD]], or [[magnetic tape]]
''Linkage editing'' ([[IBM]] nomenclature) or ''consolidation'' or ''collection'' ([[International Computers Limited|ICL]] nomenclature) refers to the ''linkage editor's'' or ''consolidator's'' act of combining the various pieces into a relocatable binary, whereas the loading and relocation into an absolute binary at the target address is normally considered a separate step.<ref name="Barron_1978_Consolidator"/>
==
In the beginning linkers gave users very limited control over the arrangement of generated output object files. As the target systems became complex with different memory requirements such as embedded systems, it became necessary to give users control to generate output object files with their specific requirements such as defining base addresses' of segments. Linkers control scripts were used for this.
== Implementations ==
Notable implementations:
=== Unix & Unix-like ===
On Unix and Unix-like systems, the static linker is
For example, on [[SINTRAN III]], linking (assembling object files into a program) was called <!--do not link to [[loader (computing)]] since that's different-->''loading'' {{endash}} as in loading executable code onto a file.<ref name="BRF_1984"/>
▲On Unix and Unix-like systems, the linker is known as "ld". Origins of the name "ld" are "LoaDer" and "Link eDitor". The term "loader" was used to describe the process of loading external symbols from other programs during the process of linking.<ref name="UNIX_V6_manuals"/>
=== GNU
==See also==
Line 70 ⟶ 82:
{{Div col|colwidth=20em}}
* [[Binary File Descriptor library]] (libbfd)
* [[Build (computing)]]
* [[Compile and go system]]
* [[DLL hell]]
Line 97 ⟶ 110:
<ref name="GNU_2018_Binutils">{{cite web |title=GNU Binutils: Linker Scripts |date=2018-07-18 |url=https://sourceware.org/binutils/docs/ld/Scripts.html |access-date=2019-01-18 |url-status=live |archive-url=https://web.archive.org/web/20200306230349/https://sourceware.org/binutils/docs/ld/Scripts.html |archive-date=2020-03-06}}</ref>
<ref name="UNIX_V6_manuals">{{cite book |title=UNIX PROGRAMMER'S MANUAL |date=May 1975 |edition=6 |chapter=1. ld }}</ref>
<ref name="Barron_1978_Consolidator">{{cite book |author-first=David William |author-last=Barron |author-link=David W. Barron |editor-first=J. John |editor-last=Floretin |title=Assemblers and Loaders |date=1978 |orig-year=1971, 1969 |edition=3 |publisher=[[Elsevier North-Holland Inc.]] |series=Computer Monographs |publication-place=New York,
<ref name="Salomon_1992">{{cite book |author-first=David |author-last=Salomon |editor-first=Ian D. |editor-last=Chivers |title=Assemblers and Loaders |date=February 1993 |chapter=8.2.3 Automatic jump-sizing |pages=237–238 |orig-year=1992 |edition=1 |series=Ellis Horwood Series In Computers And Their Applications |publisher=[[Ellis Horwood Limited]] / [[Simon & Schuster International Group]] |___location=California State University, Northridge, California,
}}
Line 105 ⟶ 118:
* {{cite book |publisher=[[International Business Machines Corporation]] |title=Operating System 360 - Linkage Editor (E) - Program Logic Manual |id=Program number 360S-ED-510. File No. S360-31. Form Y28-6610-2. |date=1969-07-23 |orig-year=June 1967 |edition=3 |url=http://www.bitsavers.org/pdf/ibm/360/Y28-6610_LinkEdit(E)_PLM.pdf |access-date=2020-03-07 |url-status=dead |archive-url=https://web.archive.org/web/20071001000734/http://www.bitsavers.org/pdf/ibm/360/Y28-6610_LinkEdit(E)_PLM.pdf |archive-date=2007-10-01}}
* {{cite journal |author-first=Douglas W. |author-last=Jones |author-link=Douglas W. Jones |title=Assembly Language as Object Code |journal=Software: Practice and Experience |volume=13 |issue=8 |date=August 1983 |publisher=[[John Wiley & Sons Ltd]] |issn=1097-024X |pages=715–725 |doi=10.1002/spe.4380130806 |s2cid=42995338 }}
* {{cite book |author-last=Levine |author-first=John R. |author-link=John R. Levine |title=Linkers and Loaders |date=2000 |orig-year=October 1999 |edition=1 |publisher=[[Morgan Kaufmann]] |series=The Morgan Kaufmann Series in Software Engineering and Programming |___location=San Francisco,
* {{cite journal |author-first1=Leon |author-last1=Presser |author-link1=Leon Presser |author-first2=John R. |author-last2=White |title=Linkers and Loaders |journal=[[ACM Computing Surveys]] |volume=4 |number=3 |___location=University of California, Santa Barbara, California,
* {{cite journal |author-first=Norman |author-last=Ramsey |title=Relocating Machine Instructions by Currying |date=May 1996 |url=https://www.cs.tufts.edu/~nr/pubs/relocating.pdf |periodical=ACM SIGPLAN Notices |volume=31 |issue=5 |pages=226–236 |doi=10.1145/249069.231429 |archive-url=https://web.archive.org/web/20200518103430/https://www.cs.tufts.edu/~nr/pubs/relocating.pdf |archive-date=18 May 2020 |url-status=live}}
== External links ==
{{Wiktionary|linker}}
* [https://www.google.com/search?q=site%3Awww.airs.com%2Fblog%2Farchives+%22linkers+part%22 Ian Lance
* [http://www.linuxjournal.com/article/6463 Linkers and Loaders], a [[Linux Journal]] article by Sandeep Grover
* [https://web.archive.org/web/20060808184333/http://www.dpgraph.com/assembly.html Another Listing of Where to Get a Complete Collection of Free Tools for Assembly Language Development]
* [https://sourceware.org/binutils/docs/ld/index.html GNU linker manual]
* [https://lld.llvm.org/ LLD - The LLVM Linker]
* {{man|1|ld|
{{Application binary interface}}
|