From 92a7dba6689846d75079092886ee2ed58755d932 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Mon, 12 Oct 2015 16:17:37 -0700 Subject: [PATCH] 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 --- mk/spdk.common.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mk/spdk.common.mk b/mk/spdk.common.mk index 70d3249ed..26690ac9d 100644 --- a/mk/spdk.common.mk +++ b/mk/spdk.common.mk @@ -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 +# 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) LIBS += -L/usr/local/lib COMMON_CFLAGS += -I/usr/local/include