summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-11-06 19:03:30 +0100
committerDirk Engling <erdgeist@erdgeist.org>2026-11-06 19:03:30 +0100
commit99a706ded2a79768ce5b850be0d4262d321aa296 (patch)
tree3f5373d5ca934f49cc5657bb859730a258d86625 /Makefile
parent879c3fab765eb10251bf177fe5fd955a32186db8 (diff)
Add hardening parameters to the default builds
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile10
1 files changed, 8 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 2b8ad92..eed77a0 100644
--- a/Makefile
+++ b/Makefile
@@ -43,6 +43,12 @@ include Mk/gzip.mk
43CFLAGS?=-O3 43CFLAGS?=-O3
44 44
45OT_CFLAGS+=-Wall -Wextra -Wwrite-strings -pipe -pthread 45OT_CFLAGS+=-Wall -Wextra -Wwrite-strings -pipe -pthread
46
47HARDENING=-fstack-protector-strong -fPIE -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
48HARDENING_LD=-pie
49# Full RELRO is free at runtime and makes the GOT read-only, but Apple's linker
50# does not accept -z, so enable it for the GNU-style linkers (Linux, the BSDs):
51#HARDENING_LD+=-Wl,-z,relro,-z,now
46OT_LDFLAGS+=-pthread 52OT_LDFLAGS+=-pthread
47 53
48OPTS_debug=-D_DEBUG -g -ggdb 54OPTS_debug=-D_DEBUG -g -ggdb
@@ -65,11 +71,11 @@ BUILDDEPS=Makefile $(BUILDSTAMP)
65all: $(BINARY) $(BINARY).debug 71all: $(BINARY) $(BINARY).debug
66 72
67$(BINARY): $(SOURCES) $(HEADERS) $(BUILDDEPS) 73$(BINARY): $(SOURCES) $(HEADERS) $(BUILDDEPS)
68 $(CC) -o $@ $(CFLAGS) $(COMPILE) $(SOURCES) $(LINK) 74 $(CC) -o $@ $(CFLAGS) $(COMPILE) $(HARDENING) $(SOURCES) $(LINK) $(HARDENING_LD)
69 $(STRIP) $@ 75 $(STRIP) $@
70 76
71$(BINARY).debug: $(SOURCES) $(HEADERS) $(BUILDDEPS) 77$(BINARY).debug: $(SOURCES) $(HEADERS) $(BUILDDEPS)
72 $(CC) -o $@ $(OPTS_debug) $(COMPILE) $(SOURCES) $(LINK) 78 $(CC) -o $@ $(OPTS_debug) $(COMPILE) $(HARDENING) $(SOURCES) $(LINK) $(HARDENING_LD)
73 79
74$(BUILDSTAMP): FORCE 80$(BUILDSTAMP): FORCE
75 @echo "$(CFLAGS) $(COMPILE) $(LINK)" | cmp -s - $@ 2>/dev/null || echo "$(CFLAGS) $(COMPILE) $(LINK)" > $@ 81 @echo "$(CFLAGS) $(COMPILE) $(LINK)" | cmp -s - $@ 2>/dev/null || echo "$(CFLAGS) $(COMPILE) $(LINK)" > $@