build: enable full RELRO in LDFLAGS

This forces the ELF loader to resolve all relocations immediately at
load time rather than allowing lazy binding.

Therefore the loader can make the GOT (global offset table) read-only
once the relocations are complete during the loading process.

Change-Id: I89a878d1060ce79d58c5be7700d8b122a33a8ceb
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Daniel Verkamp 2015-10-12 16:17:37 -07:00
parent 2a3d4b18ca
commit 92a7dba668

View File

@ -45,6 +45,10 @@ OS := $(shell uname)
COMMON_CFLAGS = -g $(C_OPT) -Wall -Werror -fno-strict-aliasing -march=native -m64 -I$(SPDK_ROOT_DIR)/include COMMON_CFLAGS = -g $(C_OPT) -Wall -Werror -fno-strict-aliasing -march=native -m64 -I$(SPDK_ROOT_DIR)/include
# Enable full RELRO - no lazy relocation (resolve everything at load time).
# This allows the GOT to be made read-only early in the loading process.
LDFLAGS += -Wl,-z,relro,-z,now
ifeq ($(OS),FreeBSD) ifeq ($(OS),FreeBSD)
LIBS += -L/usr/local/lib LIBS += -L/usr/local/lib
COMMON_CFLAGS += -I/usr/local/include COMMON_CFLAGS += -I/usr/local/include