Core · the linker
nelinker
A static linker written in Nelua for x86-64 Linux executables and UEFI applications.
Give it object files and Unix archives. It resolves symbols, applies relocations and writes an executable. The same linker performs the final link of both itself and the necc compiler driver.
Link an archive
Save start.s and answer.s in the same directory. The entry point calls answer and passes its return value to the Linux exit syscall. With GNU binutils and nelinker on your PATH, build the two objects and put the provider in an archive.
as --64 -o start.o start.s
as --64 -o answer.o answer.s
ar rcs libanswer.a answer.o
nelinker -t -o demo start.o libanswer.a
./demo
echo "$?"The link trace includes libanswer.a(answer.o). The program exits with status 42. Place an archive after the objects that reference its symbols. Use --start-group and --end-group around archives that depend on one another.
Supported inputs
In Linux mode, nelinker produces fixed-address static executables from x86-64 ELF objects. It reads regular GNU/SysV and BSD archives, resolves strong and weak symbols, and supports static GOT entries and local-exec TLS. PIE, shared libraries, thin archives, LTO and custom linker scripts are outside the current scope.
For C or Nelua programs using nelibc, let necc invoke nelinker. The driver supplies the SDK libraries and their relocation conventions.
Link a PE32+ EFI application
With --efi-app, nelinker reads freestanding x86-64 ELF objects and static archives and writes a PE32+ EFI application. The entry symbol defaults to efi_main. This command links the neboot menu with a preferred load address of 4 GiB.
nelinker --efi-app --image-base 0x100000000 -e efi_main -o BOOTX64.EFI menu.oThe linker records 64-bit absolute image pointers as DIR64 entries in .reloc so firmware can adjust them if it loads the image at another address. The neboot OVMF run shows the address firmware used.
Link times and executable sizes
On , both nelinker builds had a lower median than the fastest qualifying external linker in all 11 workloads on one Intel Core i7-11700F core. Both produced the smallest executable in five. For the single member from a 256-member archive, the distro build and TinyCC were within 0.013 ms of each other.
The first five rows use loose objects and 23 warm rounds. The remaining six use the archive harness and 31 rounds. Its explicit-syscall control also uses loose objects. Every timed link had to produce a program that returned 42. The external field consisted of GNU BFD, GNU gold, TinyCC, LLD 14, LLD 22 through Zig, mold and Wild.
| Workload | GCC-built (ms) | Distro-built (ms) | Fastest external (ms) | nelinker bytes | Smallest external bytes |
|---|---|---|---|---|---|
| Three loose objects | 1.449 | 1.454 | TinyCC · 1.526 | 205 | 727 |
| 257 loose objects | 3.123 | 3.682 | TinyCC · 5.900 | 2,491 | 3,015 |
| 32,768 relocations | 1.850 | 2.422 | GNU gold · 3.454 | 270,336 | 263,031 |
| 8,192 distinct symbols | 2.254 | 4.530 | TinyCC · 4.866 | 106,496 | 99,191 |
| SDK syscall, loose objects | 1.445 | 1.468 | TinyCC · 1.553 | 4,378 | 1,088 |
| SDK syscall, archive-suite control | 1.494 | 1.479 | TinyCC · 1.611 | 4,378 | 1,088 |
| One member from the SDK archive | 1.564 | 1.626 | TinyCC · 1.812 | 4,378 | 1,088 |
| One member from 256 | 1.501 | 1.544 | TinyCC · 1.557 | 196 | 719 |
| 256 members, reverse dependency order | 1.986 | 2.738 | Wild · 3.909 | 2,491 | 3,015 |
| All 256 archive members | 1.898 | 2.371 | Wild · 3.823 | 1,726 | 2,247 |
| Whole SDK with allocator | 3.009 | 4.527 | TinyCC · 5.795 | 995,860 | 992,583 |
The GCC build used GCC 12.2 at -O3. The distro build used necc and its staged TinyCC. The inputs and seven external binaries matched the earlier run by SHA-256. For the whole-SDK allocator, TinyCC was the only external linker whose program passed the execution check.
Full field and quartiles (CSV)Individual link times (CSV)Method, builds and checksReplay the link inputs
Link time and peak resident memory
On 21 November 2026 nelinker a349c2a linked a real SDK member and a complete Lua interpreter. Time and maximum resident set size came from separate invocations with identical inputs.
| Input | Reference | nelinker (ms) | Reference (ms) | nelinker (KiB) | Reference (KiB) |
|---|---|---|---|---|---|
| SDK getpid member | ld.bfd | 0.74 | 3.39 | 1,804 | 4,944 |
| Bundled Lua and whole SDK | TinyCC | 10.71 | 16.31 | 5,532 | 5,528 |
The syscall executable returned 42 after calling getpid. The linked Lua interpreter evaluated a command and printed 42. The table reports warm medians on one i7-9700K logical CPU.
SDK link samplesInterpreter link samplesQuartiles and observed rangesReplay scriptsVersions and reproduction
Creating an archive
On , creating a deterministic archive from 256 x86-64 objects with short filenames took 3.343 ms, down from 4.231 ms. GNU ar took 22.216 ms. The new writer stores ordinary filenames directly in the member header and preserves short filenames containing spaces. The archive shrank from 215,484 to 213,376 bytes, matching the GNU archive size.
Archive creation used 31 interleaved warm runs on one Intel Core i5-10400 core. GNU ar listed the members, nm read their index, and both nelinker and GNU ld linked a program that returned 42.
Archive creation samples (CSV)Archive writer method
19 November archive link results (CSV)19 November object and compiler results (CSV)