summaryrefslogtreecommitdiff
path: root/DESIGN
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-11-06 20:30:27 +0100
committerDirk Engling <erdgeist@erdgeist.org>2026-11-06 20:30:27 +0100
commit7792b7117bda76873ad8c5339d7441191c132703 (patch)
tree7593f5bc9a8361a9487f6e34f2f0a6a07e3f5382 /DESIGN
parent97e58519bc946daabcadc531510497c3598961a1 (diff)
take -pie out of macos hardening build flags
Diffstat (limited to 'DESIGN')
-rw-r--r--DESIGN19
1 files changed, 11 insertions, 8 deletions
diff --git a/DESIGN b/DESIGN
index b25b37c..39d0107 100644
--- a/DESIGN
+++ b/DESIGN
@@ -115,20 +115,23 @@ which costs it part of its last day and nothing else.
115Build hardening the shipped binary 115Build hardening the shipped binary
116---------------------------------- 116----------------------------------
117 117
118The production and debug binaries carry -fstack-protector-strong, PIE and 118The production and debug binaries carry -fstack-protector-strong, -fPIE and
119_FORTIFY_SOURCE=2; every linker but Apple's also gets full RELRO (-z relro,-z now). Measured cost on 119_FORTIFY_SOURCE=2 on every platform; the GNU-style linkers also get -pie and
120full RELRO (-z relro,-z now). Measured cost on
120the announce hot path is 300 to 305 nanoseconds, under two per cent, and the 121the announce hot path is 300 to 305 nanoseconds, under two per cent, and the
121individual flags sit inside the run-to-run noise: add_peer has few stack 122individual flags sit inside the run-to-run noise: add_peer has few stack
122buffers, most buffer sizes are known at compile time so FORTIFY emits no 123buffers, most buffer sizes are known at compile time so FORTIFY emits no
123runtime check, and PIE on arm64 is almost free. On x86-64 PIE costs a little 124runtime check, and PIE on arm64 is almost free. On x86-64 PIE costs a little
124more. End to end it is invisible, since a UDP announce is mostly kernel time. 125more. End to end it is invisible, since a UDP announce is mostly kernel time.
125 126
126RELRO is gated on the operating system because Apple's linker rejects -z. The 127The link flags -pie and RELRO are gated on the operating system: Apple's
127branch runs in the shell through a != assignment, the one form both bmake and 128linker rejects -z, and flags a bare -pie in the combined compile-and-link as
128GNU make 4 accept; $(shell) is GNU only and GNU make 3.81, which stock macOS 129unused, while macOS links executables PIE by default, so leaving both off
129ships, has neither. On that old make the != line is inert and leaves RELRO 130there costs no hardening. The branch runs in the shell through a != assignment,
130empty, which is the right answer for macOS anyway, so every platform resolves 131the one form both bmake and GNU make 4 accept; $(shell) is GNU only and GNU
131correctly without a make conditional. 132make 3.81, which stock macOS ships, has neither. On that old make the != line
133is inert and leaves the flags empty, which is the right answer for macOS
134anyway, so every platform resolves correctly without a make conditional.
132 135
133The flags are not in OT_CFLAGS, so the sanitizer test builds do not inherit 136The flags are not in OT_CFLAGS, so the sanitizer test builds do not inherit
134them. AddressSanitizer checks harder than FORTIFY does, and the two clash on 137them. AddressSanitizer checks harder than FORTIFY does, and the two clash on