Content deleted Content added
Idkiguessus (talk | contribs) m Reverted 1 edit by 91.64.247.199 (talk) to last revision by Engr. Smitty |
HeyElliott (talk | contribs) ce |
||
(36 intermediate revisions by 22 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]].
Line 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 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.
Line 61:
''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 ==
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"/>▼
Notable implementations:
=== GNU linker ===▼
The GNU linker (or GNU ld) is the [[GNU Project]]'s [[free software]] implementation of the Unix command ld. GNU ld runs the linker, which creates an executable file (or a library) from object files created during compilation of a software project. A ''linker script'' may be passed to GNU ld to exercise greater control over the linking process.<ref name="GNU_2018_Binutils"/> The GNU linker is part of the [[GNU Binary Utilities]] (binutils). Two versions of ld are provided in binutils: the traditional GNU ld based on [[Binary File Descriptor library|bfd]], and a "streamlined" ELF-only version called [[gold (linker)|gold]].▼
=== Unix & Unix-like ===
The command-line and linker script syntaxes of GNU ld is the ''de facto'' standard in much of the [[Unix-like]] world. The [[LLVM]] project's linker, ''{{vanchor|lld}}'', is designed to be drop-in compatible,<ref>{{cite web |title=LLD - The LLVM Linker — lld 14 documentation |url=https://lld.llvm.org/ |website=lld.llvm.org}}</ref> and may be used directly with the GNU compiler. Another drop-in replacement, mold, is a highly parallelized and faster alternative which is also supported by GNU tools.<ref>{{cite web |title=GCC 12 Adds Support For Using The Mold Linker |url=https://www.phoronix.com/scan.php?page=news_item&px=GCC-12-Mold-Linker |website=www.phoronix.com}}</ref>▼
▲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"/>
▲
▲
==See also==
Line 74 ⟶ 82:
{{Div col|colwidth=20em}}
* [[Binary File Descriptor library]] (libbfd)
* [[Build (computing)]]
* [[Compile and go system]]
* [[DLL hell]]
Line 101 ⟶ 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 109 ⟶ 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]
|