mlink -- a LINK-80 compatible linker for Microsoft REL object files
==================================================================

mlink combines Microsoft REL object files -- the format MACRO-80 and mz80
produce -- into a CP/M .COM file, an Intel HEX file or a raw binary.

It exists so that a CP/M-era toolchain can be run natively.  Until now every
link ran L80.COM under an emulator; the point of this program is that
anywhere one would have done that, one can run mlink instead.


What it does

    - Loads object files whole and SEARCHES libraries, taking only the
      modules that resolve an outstanding reference, repeating until a
      whole sweep adds nothing.
    - Both of LINK-80's layouts: data and code interleaved per module, or
      code from one origin and data and COMMON from another.
    - Resolves external reference chains, relocates every segment kind, and
      shares COMMON blocks between the modules that name them.
    - Writes .COM, Intel HEX, raw binary and .SYM.
    - Prints a load map naming every module and where it landed.

What it does differently from LINK-80

    - An undefined symbol is fatal and no output is written.  LINK-80
      writes the file anyway; an image with unresolved calls is not a
      program.
    - Space reserved with DS is zeroed, so two runs give the same image.
      LINK-80 leaves whatever was in its buffer.
    - A COMMON block takes its largest declaration rather than its first.
    - No relocating loader.  Asked for a program origin above 0103H with
      .COM output, LINK-80 writes a mover and then no program image at all;
      mlink declines the combination and suggests -b or -h.

The manual's Compatibility chapter sets out all of it, with the evidence.


Building and installing

    make ; sudo make install

There is no configure script.  The linking core comes from librel, which
mlink, mz80, gen and the reconstruction tools all share; point LIBREL
elsewhere if that tree is not beside this one.


Testing

    make test

Two groups.  Behavioural tests assert what mlink must do, including the
cases LINK-80 cannot serve as an oracle for because it declines to link them
at all.  Then eight configurations are linked twice -- once with mlink, once
with the real LINK-80 3.44 under emulation -- and the images compared byte
for byte:

    links identical=8  differ=0

The twenty-module cases are there because an off-by-one in the layout
arithmetic does not show over two modules.


Files

    mlink.h      the option state and the interfaces
    main.c       the command line and the link driver
    layout.c     where LINK-80 puts things
    libsearch.c  loading a file, and searching a library
    map.c        the load map and the undefined list

    mlink.1           the manual page
    mlink_manual.tex  the manual
    tests/            the test suite


Licence

BSD 2-Clause; see the head of any source file.
