Repository navigation
Enable full RELRO - #119037
Enable full RELRO#119037
Conversation
Link executables with `-z relro -z now`, so that all dynamic relocations are resolved at startup and the global offset table is mapped read-only afterwards. Previously only the linker default applied, which leaves the table writable for the lifetime of the process, so an arbitrary write could redirect a call through it. Resolving everything at startup is free here: we link dynamically only against libc and we forbid `dlopen`. Not enabled on Darwin, where `ld64` does not accept `-z` options. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [274f40b] Summary: ✅
AI ReviewSummaryThis PR adds Findings
Final VerdictChanges requested: narrow the condition to the supported ELF targets before merging. LLVM Coverage ReportMeasured on commit 274f40b.
Changed lines: Uncovered code analysis did not run: No coverable C/C++ source files changed (contrib/ is excluded from coverage). Newly covered: +343 lines in 90 files (-149 lines lost coverage) · Details |
| # Resolving everything at startup costs nothing here because we link dynamically only against libc | ||
| # and we forbid dlopen (see programs/main.cpp). | ||
| # Not on Darwin: ld64 does not accept '-z' options. | ||
| if (NOT OS_DARWIN) |
There was a problem hiding this comment.
NOT OS_DARWIN is broader than the set of targets that actually have ELF RELRO/NOW semantics. This tree still has an OS_WASM configuration, and cmake/tools.cmake routes it through emcc/wasm-ld, so this condition forwards ELF-only -z flags to a non-ELF link step where the promised GOT hardening cannot happen.
Please gate this on the actual ELF platforms we support instead of every non-Darwin target.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units6 translation units recompiled, 4 s compile time in total, 6 of them have a recent master baseline. |
|
No noticeable performance changes |
c625830
Link executables with
-z relro -z now. All dynamic relocations are resolved at startup and the global offset table is mapped read-only afterwards. Previously only the linker default applied, which leaves the table writable for the lifetime of the process, so an arbitrary write could redirect a call through it.Resolving everything at startup is free here: we link dynamically only against libc and we forbid
dlopen.Not enabled on Darwin, where
ld64does not accept-zoptions.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Harden official builds by enabling full RELRO: the global offset table is now mapped read-only after startup.
Workflow [PR]
Sync PR [sync-upstream/pr/119037]
Version info
26.9.1.1121(included in26.9and later)