Skip to content

Commit

Permalink
Add hardening flags to our compile.
Browse files Browse the repository at this point in the history
This makes us fully position independant and have a noexec stack.  There's a
small chance that the former part of that can interfere with
gdb/corefiles/stackdumps, but we'll handle that if it becomes a problem.
  • Loading branch information
alexmiller-apple committed Dec 2, 2017
1 parent 482ac38 commit f578806
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ ACTORCOMPILER := bin/actorcompiler.exe

# UNSTRIPPED := 1

HARDENING_FLAGS := -fstack-protector-all -Wstack-protector --param ssp-buffer-size=4 -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now
# TODO(alexmiller): boost 1.52.0 prevents us from using most of these with -Werror.
# Reassess after boost has been upgraded to >1.52.0.
#WARNING_FLAGS ?= -Wall -Wextra -Wformat-security -Wconversion -Wsign-conversion -Werror

CFLAGS += ${HARDENING_FLAGS} ${WARNING_FLAGS}

# Normal optimization level
CFLAGS += -O2

Expand All @@ -84,7 +91,7 @@ CFLAGS += -g
# valgrind-compatibile builds are enabled by uncommenting lines in valgind.mk

CXXFLAGS += -Wno-deprecated
LDFLAGS :=
LDFLAGS := ${HARDENING_FLAGS}
LIBS :=
STATIC_LIBS :=

Expand Down
2 changes: 1 addition & 1 deletion build/link-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ case $1 in
OPTIONS="$OPTIONS -Wl,-dylib_install_name -Wl,$( basename $3 )"
fi
else
OPTIONS=
OPTIONS="$OPTIONS -pie -fPIE"
fi

OPTIONS=$( eval echo "$OPTIONS $LDFLAGS \$$2_LDFLAGS \$$2_OBJECTS \$$2_LIBS \$$2_STATIC_LIBS_REAL -o $3" )
Expand Down

0 comments on commit f578806

Please sign in to comment.