Master the fundamental concepts of linkers & loaders through this focused micro-challenge.
Static linking merges all .o files and libraries into a single binary. LLD, GNU ld, and MSVC's link.exe assign final addresses, resolve symbols, apply relocations, and emit the executable. No runtime loader needed beyond the OS program loader.
Collect input objects. Lay out sections (VMA/LMA). Resolve symbols: each undefined gets a definition's address. Apply relocations. Emit ELF executable with entry point _start or main.
cLoading…
--gc-sections drops unreferenced codeProduction compilers embed this step inside a longer pipeline. GCC flows through cpp, cc1, assembly, and ld; Clang uses the driver, Sema, LLVM IR passes, and a target backend. LLVM bitcode, JVM bytecode, and WASM are other familiar IRs at the same layer. The exercise isolates one pass so you can test it alone before chaining it to the next stage.
You will implement a simple static linker that merges object files. This exercise requires resolving symbols, laying out sections, applying relocations, and writing a minimal executable image.
Implement simple static linker for multiple object files.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github