
Beginner's Guide to Linkers (2010) - ingve
http://www.lurklurk.org/linkers/linkers.html
======
weinzierl
Best piece on linkers is in my opinion Ian Lance Taylor's (author of the gold
linker) write up[1].

It obviously has been written in a hurry and could need some polish but the
content is gold. LWN published an overview with links to the different parts,
to make it a little more accessible[2]. I always hoped Ian would turn it into
the book he mentioned in the post.

[1]
[https://www.airs.com/blog/archives/38](https://www.airs.com/blog/archives/38)

[2] [https://lwn.net/Articles/276782/](https://lwn.net/Articles/276782/)

------
CalChris
Also, Ulrich Drepper's _How To Write Shared Libraries_ [1] and _ELF Handling
For Thread-Local Storage_ [2].

[1]
[https://www.akkadia.org/drepper/dsohowto.pdf](https://www.akkadia.org/drepper/dsohowto.pdf)

[2]
[https://www.akkadia.org/drepper/tls.pdf](https://www.akkadia.org/drepper/tls.pdf)

------
blinkingled
Solaris Linkers and Libraries Guide (PDF/html free on Oracle's site) is also
an excellent resource - it is Solaris specific, but it's still good for
understanding general concepts.

~~~
throwaway8941
[https://docs.oracle.com/cd/E53394_01/pdf/E54813.pdf](https://docs.oracle.com/cd/E53394_01/pdf/E54813.pdf)

------
marcocampos
Question: Is Linkers & Loaders by John R. Levine still a good book?

~~~
CalChris
Yes. It definitely stands the test of time. It covers several formats (elf,
coff, pef, ..., not macho), linker scripts, and explains some old design
decisions. You’ll understand object file formats much better, and the
fundamental processes of relocation, ... having read Levine. Gold and LLD are
(much) faster but they’re still doing the same thing.

~~~
tempguy9999
And here's Levine's comments FYI
[https://news.ycombinator.com/threads?id=spamvictim](https://news.ycombinator.com/threads?id=spamvictim)

------
signa11
i found this: [https://a3f.at/lists/linkers](https://a3f.at/lists/linkers) ,
to be a slightly more in depth article than this one.

------
account42
Why does MSVC actually need import libraries? It seems MinGW is able to link
against just the .DLL without problems even on Windows.

~~~
_old_dude_
The DLL API is not stable in the Windows world, only the libraries are stable.

~~~
intea
Can you elaborate here? One of the Ls in DLL stands for library after all.

------
QuamStiver
Similar to this, can anyone recommend a good book on linking/loading? I'm
mostly looking for something about the process in Linux, but a general
reference to common techniques would also be an interesting read. Bonus points
if it was published this century.

~~~
CalChris
As mentioned above, _Linkers & Loaders_ by John R. Levine is still a fine
book, the Dragon Book of linking. Basically, linking hasn't changed much in 70
years with the minor exception of shared libraries. So I'd recommend that and
the Oracle® Solaris 11.3 Linkers and Libraries Guide is 534 pages and gives
you an idea of every feature in a fully supported linker. It is ELF specific.

I'd skip gold (ELF specific, GPL) and just study LLD (faster, ELF, COFF,
mach-O, BSD). Avoid GNU ld altogether. Adding support to LLD for RISC-V was
like a couple of hundred lines of code. Peter Smith has a couple of good talks
on LLD.

[https://www.youtube.com/watch?v=FiBg0jg4pHk](https://www.youtube.com/watch?v=FiBg0jg4pHk)

[https://archive.fosdem.org/2019/schedule/event/llvm_lld/](https://archive.fosdem.org/2019/schedule/event/llvm_lld/)

