Linkers

Traditionally, you can't get far without a linker, and thats a fact.

Linkers are important tools in the production of an Operating System.

They come in many flavours sizes shapes and formats. Some are flexable and some are not.

There are important considerations to make when using a linker.

Does it support the output formats I require

Some linkers only support one kind of output file format, others support every kind of format know to exist. Formats are often not proprietory, having specifications available means if you wish to use Win32/PE file format, you are not required to use Microsoft's Linker.

Does it support the input formats I'm using?

This can be important if your going to mix files around. For example, stock DJGPP distribution works with COFF files, and if you link in a TASM assembled OBJ/OMF file, DJGPP(LD) will not recognised it.

This is usually of less a concern than the other requirements.

Can I specify address ranges for code and data?

This can be very, very important! Especially if you want to product flat binary files. (Like an unrelocated kernel image). You need to be able to specify where the code starts and sometimes where the data begins.

Can I produce flat binary files?

As with the above option, this can be important, even if you only need to use it a couple of times.

Can it handle 32bit code?

You might think this a redundant question in the age of "32bit" but there are many custom linkers out there that can't handle 32bit object files.

 

Linkers :: JLoc

JLoc is written by John Fines.

"This program is a linker/locator for use when you need more
control over placement of sections within the image, than a standard
linker provides."
		

JLoc can be tricky to use for first timers. Carefull reading of the documentation is required. Its not a get-up-and-go linker like all the other linkers. JLoc _requires_ you to write a custome script for each "executable" image you want to link.

JLoc gives you flexibility over HOW the object files are linked, regarding loaded addresses and so-forth.

JLoc can be obtained here, http://www.erols.com/johnfine/

needs more review!!

Pros

  • Supports OMF/OBJ, DJGPP/COFF
  • Supports 32bit code
  • Supports flat binary file generation
  • Handles library files (OMF/OBJ)
  • OMF/OBJ debugging information
  • Free

Cons

  • Does not support any output file formats other than flat binary and DOS/COM
  • Confusing to use for beginners
  • Can't create shared libraries

 

Linkers :: ALink

ALink (Anthony's Linker) was written as a companion to NASM, its aim to provide a Free linker that supports Nasm's output formats and support some of the more popular executable formats.

ALink can be obtained here, http://www.geocities.com/SiliconValley/Network/4311/index.html

need more of a review!!

Pros

  • Its Free
  • Supports input formats OMF/OBJ, Win32/COFF Objects
  • Supports output as DOS/COM, DOS/EXE, Win32/PE
  • Can build Win32/PE DLL files
  • Can set the code address
  • Suppots .LIB (OBJ) Library files

Cons

  • Doesnt support flat binary images
  • Strips debugging information
  • Can't create shared libraries

 

Linkers :: LD (GNU)

LD, the King of linkers. Supports more input and output formats than any other linker in existance. Also the most flexable of the listed linkers. Supports custom linking via scripts. Its advanced featers are hard to use if you dont know what you are doing.

LD has the most going for it in terms of functionality compared to the other linkers (Thats _my_ opinion anyway...) but lacking OMF/OBJ support is a BIG omission.

This description is based on the LD sources, that can compile to support all formats. Please be aware that the LD that comes with DJGPP is very limited in its output formats (DJGPP/COFF, A.Out, flat binary) and so to with the LD that is part of Linux etc.

Pros

  • Supports most known input formats (Elf, DJGPP/COFF, Win32/COFF, A.Out, etc)
  • Supports most known output formats (Elf, Win32/PE, A.Out, COFF, etc)
  • Supports creation of shared libraries
  • Can create flat binary files
  • Can specify code/data addresses
  • Supports DWARF and ECOFF and STABS debugging information
  • Its Free

Cons

  • Does not support OMF/OBJ file format
  • Can get complex writing custom linking scripts
  • Can't create shared libraries

 

Linkers :: TLink / TLink32 (Borland)

TLink is the linker that comes with Borland C and their assembler TASM. The difference between TLink and TLink32 is that TLink32 creates ONLY Win32/PE (and DLL) files where as TLink creates Dos and Win16 files.

Pros

  • Supports Win32/COFF and OMF/OBJ
  • Has support for libraries
  • Supports creating Win32/PE files and DLL's
  • Supports OMF/OBJ (and DWARF?) debugging information

Cons

  • Lacking in both input and output fileformats
  • Can't create flat binary images
  • Can't create shared libraries

 

Linkers :: Link / NLink (Microsoft)

There are really three fundamentally different linkers.

Versions 1.x through 3.x can only produce DOS output. Technically, the _really_ early ones can only produce .com files, and IIRC, starting with 2.x they can also produce .exe files.

Starting with version 4.x, MS Link can also produce NE format output files. These accept OMF/OBJ format with some MS extensions.

Starting with version 6.x, MS link can produce only PE format output files.

These accept either COFF/PE or 32-bit OMF/OBJ format object files and produce (only) PE files as output. They support a few things missing from the Borland linker such as the ability to specify the entry point. Debug formats supported include COFF and CodeView.

Here I should note that I'm listing only the relatively mainstream versions of MS link. They've also produced versions that produce various other formats of output, mostly for OS/2 and/or Windows 3.x VxDs (e.g. LE and LX format).

 

Linkers :: VAL

VALink is an old old linker that has been floating around for ages. It is showing its age quite well.

There exists an Enhnaced VALink that needs a review!

Pros

  • Its free
  • Supports makeing DOS/EXE files.

Cons

  • Can ONLY handle 16bit code.

 

Linkers :: WLink (Watcom Linker)

WLink is the linker that comes with Watcom C/C++. Supports a wide range of options and is flexable to a degree.

But it can be quite braindead at times and its support for generating ELF files is broken and seriously flawed.

Pros

  • Supports range of input formats, OMF/OBJ, Win32/COFF, ELF
  • Supports library files
  • Supports many output file formats from EXE, LE, Win32/PE, Novell NLM files, Pharlap files, QNX, OS2, etc.
  • Handles setting code offset address
  • Supports Watcom, Codeview and Dward debugging information

Cons

  • ELF output is broken
  • Cant do flat binary files

 

Comparisson

Name Input Output Flat Binary Images Set Code
Address
Library
Support
Supports Debug Info 32bit Code
JLoc OMF/OBJ DOS/COM Y Y N OMF/OBJ Y
ALink OMF/OBJ
Win32/COFF
DJGPP/COFF
DOS/COM
DOS/EXE
Win32/PE
Win32/DLL
N Y Y N Y
LD OMF/OBJ
OMF/COFF
DJGPP/COFF
Win32/COFF
A.OUT
ELF
ELF
A.OUT
Win32/PE
Win32/DLL
+more
Y Y Y ECOFF
DWARF
STABS
Y
Tlink
Tlink32
OMF/OBJ
Win32/COFF
DOS/EXE
DOS/COM
Win32/DLL
Win32/PE
N Y Y OMF/OBJ Y
Link
NLink
OMF/OBJ, Win32/COFF DOS/EXE
DOS/COM
Win32/PE
Win32/DLL
LE
N Y Y CODEVIEW
DWARF
Y
Val OMF/OBJ DOS/EXE N N N Y N
Wlink OMF/OBJ
Win32/COFF
ELF
DOS/EXE
DOS/COM
LE
ELF
Win32/PE
Win32/DLL
Pharlap
Novell NLM
Causeway
QNX
N Y Y WATCOM
CODEVIEW
DWARF
Y