Skip to content
briar-systemsPublic

About

The mink linker and object formats of the mach toolchain

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

mink

CI License

The linker and object format library of the mach toolchain, written in Mach.

mink reads relocatable objects, archives and shared libraries from any producer (GCC, clang, rustc, Go, MSVC, the Apple tools and the mach toolchain alike) and writes executables, shared libraries, relocatable objects and flat images. It speaks ELF, PE/COFF, Mach-O, the archive formats, WebAssembly and SPIR-V. Nothing in mink assumes its input came from mach.

mink is a library first. A compiler links through its API in process, and the mink program is a thin command line over the same API. It reads no configuration file: everything a link needs comes from the command line, a link plan or the API.

mink is early work. The design is settled but most of what is described here is not built yet.

Place in the toolchain

The mach toolchain is four projects, each depending only on the layers below it.

mach   language front end
 └ mirl   IR and code generation
    └ masc   assembler
       └ mink   linker and object formats

mink is the lowest layer. It depends on nothing but the Mach standard library and a few protocol packages, such as compression for compressed sections.

Architecture

  • Format modules. One module per object format, each holding the complete model of its specification with a reader and a writer. Reading an input and writing it back gives the same bytes.
  • The neutral object model. The form the linker works in: sections, symbols, relocations and groups, designed against the union of the formats. Each format converts its own model to and from it.
  • Catalogs and relocation tables. Architectures, operating systems and the relocations of each format and architecture pair are rows of data. Adding an architecture, a format or a system adds rows and a module, never a rewrite.
  • The link phases. A link is one state record run through fixed phases: gather and settle inputs, resolve symbols, collect garbage, reserve linker-made tables, lay out, apply relocations and write the image.
  • The program. mink links from the command line, and mink dump prints any object, archive or image as text.

Building

mink is built with the current release of the Mach compiler.

git clone https://github.com/briar-systems/mink.git
cd mink
mach dep pull .
mach build .
mach test .

License

MIT

About

The mink linker and object formats of the mach toolchain

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages