Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardening compiler flags #578

Merged
merged 1 commit into from
Jan 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,23 @@ endif
endif
endif

CFLAGS += -O2 -fno-omit-frame-pointer -g
CFLAGS += -O2 -g
# Get better runtime backtraces by preserving the frame pointer. This eats
# one of seven precious registers on x86, but our functions are quite large
# so they almost always use stack and need the frame pointer anyway.
CFLAGS += -fno-omit-frame-pointer
# Enable runtime stack canaries for functions to guard for buffer overflows.
ifeq (yes,$(call supported,-fstack-protector-strong))
CFLAGS += -fstack-protector-strong
else
CFLAGS += -fstack-protector
endif
# Enable miscellaneous compile-time checks in standard library usage.
CFLAGS += -D_FORTIFY_SOURCE=2
# Prevent global offset table overwrite attacks.
ifdef IS_LINUX
LDFLAGS += -Wl,-z,relro -Wl,-z,now
endif

ifdef COVERAGE
CFLAGS += -O0 --coverage
Expand Down