Nelua

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.

nelinker source on GitHub

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.o

The 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.

WorkloadGCC-built (ms)Distro-built (ms)Fastest external (ms)nelinker bytesSmallest external bytes
Three loose objects1.4491.454TinyCC · 1.526205727
257 loose objects3.1233.682TinyCC · 5.9002,4913,015
32,768 relocations1.8502.422GNU gold · 3.454270,336263,031
8,192 distinct symbols2.2544.530TinyCC · 4.866106,49699,191
SDK syscall, loose objects1.4451.468TinyCC · 1.5534,3781,088
SDK syscall, archive-suite control1.4941.479TinyCC · 1.6114,3781,088
One member from the SDK archive1.5641.626TinyCC · 1.8124,3781,088
One member from 2561.5011.544TinyCC · 1.557196719
256 members, reverse dependency order1.9862.738Wild · 3.9092,4913,015
All 256 archive members1.8982.371Wild · 3.8231,7262,247
Whole SDK with allocator3.0094.527TinyCC · 5.795995,860992,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.

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.

InputReferencenelinker (ms)Reference (ms)nelinker (KiB)Reference (KiB)
SDK getpid memberld.bfd0.743.391,8044,944
Bundled Lua and whole SDKTinyCC10.7116.315,5325,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.

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.