Skip to content

lld: pack Relocation to 16 bytes (fork-local) - #39

Open
julesjacobs wants to merge 2 commits into
ocaml-flambda:19.1.7from
julesjacobs:jj/lld-reloc-16b
Open

lld: pack Relocation to 16 bytes (fork-local)#39
julesjacobs wants to merge 2 commits into
ocaml-flambda:19.1.7from
julesjacobs:jj/lld-reloc-16b

Conversation

@julesjacobs

@julesjacobs julesjacobs commented Jul 15, 2026

Copy link
Copy Markdown

Stacked on #38 — this PR's diff includes both commits; review only the second commit ("Pack Relocation to 16 bytes").

Builds on the 24-byte layout by additionally narrowing offset to uint32_t and addend to int32_t, reaching 16 bytes — half the original 32. This caps section-relative offsets at 4 GiB and addends at signed 32-bit, so it is a fork-local layout rather than an upstream candidate.

Removes 16 bytes per input relocation from the linker peak footprint: 0.30-0.60 GB per link on 1-2 GB executables with 19-38M relocations. That is 26-30% of the linker anonymous (heap) peak, and 7-8% of whole-process peak on these binaries, whose total is dominated by the file-backed mmap of the output image; the whole-process fraction rises toward the anon figure for smaller outputs. The anon figure is the one that matters for OOMs: under a cgroup memory limit with swap off, anon pages are unreclaimable, while file-backed pages can be written back and dropped under pressure.

Validated as a drop-in against the current production linker (base commit e3c0054): byte-identical output on 54 real links — 52 executables from 80 MB to 2 GB, a shared object, and a linker-script link. Inputs whose section offset exceeds 4 GiB or whose addend falls outside signed 32-bit are rejected with a fatal error rather than silently truncated; the guard never fires on real inputs (observed values sit orders of magnitude inside the bounds) and correctly rejects a synthetic out-of-range addend that the current linker silently truncates.

julesjacobs and others added 2 commits July 15, 2026 12:03
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant