lld: pack Relocation to 16 bytes (fork-local) - #39
Open
julesjacobs wants to merge 2 commits into
Open
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
offsettouint32_tandaddendtoint32_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.