vlink

A portable linker for multiple file formats.
About vlink
Last release source
Daily source snapshot
Tagged source archives
Compilation notes
Last release binaries
Daily snapshot binaries
vlink docs (pdf)
Volker's vlink page
vbcc/Amiga home page

vlink is a portable linker, written in ANSI-C, that can read and write a wide range of object- and executable file formats. It can be used to link a specific target format from several different input file formats, or for converting, stripping and manipulating files.

The linker can be controlled by GNU-style linker scripts to generate absolute code, but it also runs very well with default rules to create relocatable executables, as required for AmigaOS or MorphOS.

Of course there might be technical restrictions that object files of different architectures cannot be merged because of incompatible relocation types, differing endianess or symbol-names with and without leading underscores. But in theory everything is possible!

Currently the following object and executable file formats are supported by vlink:
  • a.out generic
  • a.out Jaguar (M68k with support for RISC relocations)
  • a.out MiNT (embedded in Atari TOS format)
  • a.out NetBSD/68k (4k and 8k pages)
  • a.out NetBSD/386
  • a.out PC/386
  • a.out Sun/010 (also Amiga/Atari 68000)
  • a.out Sun/020 (also Amiga/Atari 68020+)
  • AmigaOS hunk format
  • Apple OMF format (Apple IIgs)
  • Atari TOS/DRI format
  • EHF, extended hunk format (WarpOS)
  • ELF 32bit ARM little endian
  • ELF 32bit Jaguar RISC big endian
  • ELF 32bit M68k big endian
  • ELF 32bit PowerPC big endian
  • ELF 32bit PowerPC AmigaOS (special dynamic linking rules)
  • ELF 32bit PowerPC MorphOS (relocatable executables)
  • ELF 32bit PowerPC PowerUp (relocatable executables)
  • ELF 32bit x86 little endian
  • ELF 32bit x86 AROS (relocatable executables)
  • ELF 64bit x86_64 little endian
  • o65 binary relocation format V1.3 (6502 and 65816)
  • OS-9/6809 modules (writing only)
  • VOBJ, proprietary versatile object format
And the following binary output formats (usually absolute, without relocation information) are currently supported:
  • AMSDOS format (Amstrad/Schneider CPC)
  • Apple DOS 3.3 binary format (Apple II)
  • Atari 8-bit COM format (400, 600, 800, etc.)
  • BBC Micro/Master (.inf for emulator)
  • Commodore 8-bit PRG format (PET, VIC-20, 64, etc.)
  • Dragon DOS binary files (Dragon 32 and 64)
  • Foenix PGX format (65C02 and 65816)
  • Foenix PGZ format (24 and 32 bit)
  • Intel-hex format (writing only)
  • Motorola S-Records (writing only)
  • Oric machine code file format (Oric-1, Atmos, Telestrat, Pravetz)
  • Raw binaries (writing only)
  • Sinclair QL binary format with QDOS header or XTcc trailer
  • Tandy Color Computer machine language files (CoCo 1, 2 and 3)


31-Dec-2024: vlink 0.18.
  • Define for each relocation type whether it is signed, unsigned or unknown, to provide better range checks.
  • Make the range-checking work with sign-extended addresses (Example: m68k 16-bit absolute addressing).
  • When an output section's memory region has not enough space the linker will look for the next matching output section.
  • Linker script function KEEP() now really prevents garbage collection of sections.
  • Sorting and exclusion functions for linker script section patterns: SORT_BY_ALIGNMENT(), SORT_BY_NAME(), SORT_BY_SIZE(), REVERSE(), EXCLUDE_FILE(), EXCLUDE_SECTION(). Supporting up to two sorting levels.
  • The output section's bank size can be defined by (BANKSIZE=n) in the script, so input sections may not cross bank borders. In that case they will be aligned to the beginning of the next bank.
  • Linker script MEMORY definitions now support an optional ID=n argument, where n defines an identification value which can be referenced by a VOBJ-specific relocation type (MEMID).
  • Can find first executable code-section now, when no start symbol is present.
  • Portable pattern matching routine, used for Windows and TOS, did case-insensitive string comparisons in the past.
  • Absolute symbols are printed as a separate section into the map file.
  • Support LINKONCE section flag.
  • New options -symfile, -symfmt and -symctrl to output symbol/value pairs into a file using the given printf-format string.
  • New options -obe and -ole to specify the endianess of octets within a target-byte (when it has more than 8 bits) when writing the contents of a section to a file system.
  • New option -lineoffsets to output a separate file with source line offsets per section.
  • New option -mattr to merge all sections with same attributes, when linking without a linker script.
  • The target file formats rawbin1 and rawbin2 were replaced by a common rawbin format. rawbin2 is now -brawbin with -multifile option. The old target names are still supported for backwards compatibility.
  • New target file formats "foenixpgx-c02", "foenixpgx-816", "foenixpgz-24" and "foenixpgz-32" for Foenix retro computers.
  • New target file format "appleomf" can generate relocatable load-files for Apple IIgs computers.
  • Merge options -mrel, -mtype and -mall also work with -r now, when creating a new relocatable object file.
  • Linker script commands BYTE, SHORT, LONG, QUAD, SQUAD do now create 1, 2, 4 or 8 target-bytes and no longer 8, 16, 32, 64-bit values.
  • Relocatable/Abs symbols with the same name have precedence before Common symbols and do not cause a multiple-definition error.
  • Starting vlink without arguments only shows a short list of options now. For a detailed description use -h, which also includes target-specific options selected by -b.
  • Fixed output section trimming in the linker script.
  • Fix error message for unknown target file formats (-b).
  • (ados/ehf) New option -kick1 makes sure the generated executable is comaptible with the Kickstart 1.x loader.
  • (ados/ehf) Allow symbol redefinitions from pulled library units, as long as their target CPU differs (M68k/PPC WarpOS mixed binaries). This only worked for symbols from code sections, since V0.17.
  • (elf) Fixed uninitialized .plt at end of text segment.
  • (tos) Can use DRI object files and libraries as input now. HiSoft and SozobonX symbol name extensions are supported.
  • (tos) TOS executable files do work as input and DRI objects as output (-r).
  • (tos) Enable SozobonX symbol names with -tos-sozobonx.
  • (tos) Disable the HiSoft symbol name extension in executables with -tos-stddri.
  • (rawbin) Fixed missing byte in the ORIC tape header and automatically remove a ".tap" extension from the name stored there.
  • (rawbin) IHEX supports architectures with more than 8 bits per byte. But note that the address is still incremented in 8-bit steps.
  • (rawbin) Make sure the file size is even, when using a QDOS header.
  • (rawbin) Fixed raw reloc table output (-q) for a relocation at offset 0.
  • (rawbin) New options -fill, -coalesced and -multifile (previously rawbin2).
  • (vobj) Supports -r option to output a relocatable VOBJ file. Option -vobj2 may be used to write that file in VOBJ v2 format.
  • (vobj) -vobjcpu option selects the name of the target CPU.
  • (vobj) Supports VOBJ v2 format (vasm -Fvobj -vobj2) and PPC non-standard relocations (EABI, MorphOS, AmigaOS).
  • (xfile) Entry address is written to the header.
  • (xfile) New option -x-high sets the high-address flag in the header.


22-Sep-2022: vlink 0.17a.
  • Fixed segfault following a syntax error in the linker script.
  • Allow '-' in the linker script for section names.
  • Fixed support for masked symbols (-m option).
  • No more "out of memory" when trying to read (Linux) directories.
  • -baseoff option was broken in the last release. Fixed.
  • Make sure symbol definitions from already linked object units have priority.
  • Reworked some error messages. Print signed values and mask output according to target address size.
  • New option -wfail makes vlink return with an error code not only for errors but also for warnings.
  • (ados/ehf) Enabled masked symbol support.
  • (ados/ehf) Sections from executables get a unique name made out of their type and memory flags.
  • (elf) NOLOAD sections should not be part of any load-segment.
  • (elf) Enabled support for R_NONE relocations.
  • (vobj) Enabled support for R_NONE relocations.


26-Feb-2022: vlink 0.17.
  • Fixed bug when linking different object file formats.
  • Fixed malformatted output of some error codes for 32-bit hosts.
  • The string "DONTMERGE_" within a section name is replaced by a unique id to optionally prevent merging with any other section.
  • Report global symbol name conflicts from linked library objects, except when their definition sections belong to different architectures (needed for linking mixed binaries, like WarpOS 68k/PPC).
  • Fixed random values from illegal arguments for various "-opt <n>" style options.
  • Target format option (-b) is now parsed before any other option, so target-specific options may appear in front of it again.
  • (rawbin) Fixed output of leading empty sections, which don't have the NOLOAD flag.
  • (rawbin) Fixed file size in AMSDOS header at offset 64.
  • (a.out) aoutnull must default to 32 bit addresses.
  • (a.out) Make baserel (small-data) relocations compatible to GNU-binutils.
  • (ados/ehf) Fixed recognition of EHF objects and libraries.
  • (ados/ehf) Ignore free-floating debug hunks (SAS/C debug?).
  • (ados/ehf) New option -broken-debug.
  • (ados/ehf) Fastcall-ABI constructors/destructors (symbol names starting with '@' instead of '_') replace standard ones, when priority and name is otherwise identical.
  • (ados/ehf) Fixed EHF symbol redefinition bug since V0.16f.
  • (tos) Make sure data section size is even. No longer try to add the uninitialized data part to bss.


28-Apr-2021: vlink 0.16h.
  • Prepared the code to work with architectures which don't use 8-bit bytes. Currently it should work with multiples of 8 bits.
  • New target file formats "o65-02" and "o65-816" can read and write object files and executables in the o65 format by Andre Fachat.
  • New target file format "oricmc" writes a machine code file header for Oric computers. Supports optional auto-exec (-autox).
  • New target file format "sinclairql" writes binary files for Sinclair QL emulators using either a QDOS header or a XTcc trailer and an optional reloc table.
  • New option -nowarn=n to not display a specific warning message.
  • Now the linker searches in all paths defined by -L first, before finally looking into the local directly.
  • -Ttext <addr> may define the start address of absolute code even without a linker script.
  • Some options are really target-specific now, and not available when a different target is selected.
  • Fixed a rare bug when merging sections with the same type and linking without a linker script.
  • Undefined symbols declared on the command line (-u) or in the linker script (EXTERN) allocated 4 bytes at the end of the first section. Fixed.
  • (vobj) Section attributes 'c' and 'x' both select type=code and set the executable flag. Otherwise "rx" would be classified as data.
  • (rawseg) Fixed relocations to linker-script symbols in unallocated sections.


31-Dec-2020: vlink 0.16g.
  • New target file format bbc to generate .inf files for BBC Micro/Master.
  • Fixed symbol assignments referring to other symbols in linker scripts.
  • Optional symbol assignments can be done with =?. Such an assignment will be silently ignored when the symbol already exists.
  • New option -D to define linker symbols on the command line.
  • ASCII output (S-Rec, ihex, etc.) is now done using the host systems line endings.
  • When calculated relocation addends in raw binary formats are out of bounds, also print the name and section-offset of the input file.
  • (os9) -os9-mem now specifies the memory to allocate in bytes instead of pages.
  • (os9) Fixed header parity and CRC calculation.
  • (os9) Fixed write error when vlink was not compiled by gcc.
  • (rawbin) -q can be used with rawbin1 to append a relocation table.
  • (rawseg) -q (emit relocations) is now supported for any target address size.


28-Sep-2020: vlink 0.16f.
  • New target file format os9-6809 to generate OS-9 modules for 6809 systems.
  • OS9-specific options: -os9-mem, -os9-name, -os9-ns, -os9-rev.
  • New binary target file formats applebin (Apple DOS 3.3), ataricom (Atari 8-bit), cocoml (Tandy Color Computer) and dragonbin (Dragon DOS).
  • New option -m enables special treatment of a feature-mask suffix in symbol names (global definitions and external references).
  • New option -Crel emits constructor/destructor function references which are relative to their table position.
  • Added cbmreu target for C64 REU memory expansion.
  • New linker script functions ORIGIN() and LENGTH() for memory regions.
  • Included description of linker scripts in the documentation.
  • Fixed bug with AT(lma) attribute in linker script section definitions.
  • (elf) Fixed reference to defined weak-symbols again.
  • (ados/ehf) External small-data references may have a signed addend now, while small-data relocs still use an unsigned section-offset.

$Id: index.php,v 1.16 2023/09/30 11:57:36 frank Exp $