Skip to content

Commit c183961

Browse files
tkanteckmdcornu
authored andcommitted
build: enable full read-only relocations and control flow integrity for hardening check
Signed-off-by: Tomasz Kantecki <[email protected]>
1 parent 809f536 commit c183961

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

configure.ac

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,18 @@ my_CFLAGS="\
285285
-Wshadow \
286286
-Wstrict-prototypes \
287287
-Wtype-limits \
288+
-fstack-protector \
289+
-D_FORTIFY_SOURCE=2 \
288290
"
289291
AC_SUBST([my_CFLAGS])
290292

293+
AM_LDFLAGS="\
294+
-Wl,-z,noexecstack \
295+
-Wl,-z,relro \
296+
-Wl,-z,now \
297+
"
298+
AC_SUBST([AM_LDFLAGS])
299+
291300
AC_CONFIG_FILES([\
292301
Makefile\
293302
libisal.pc

make.inc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ DEBUG_yasm = -g dwarf2
5757
DEBUG_nasm = -g
5858

5959
# Default arch= build options
60-
CFLAGS_ = -Wall
60+
CFLAGS_ = -Wall -Wchar-subscripts -Wformat-security -Wnested-externs -Wpointer-arith -Wshadow -Wstrict-prototypes -Wtype-limits -fstack-protector -D_FORTIFY_SOURCE=2
6161
ASFLAGS_ = -f elf64
6262
ARFLAGS_ = cr $@
6363
STRIP_gcc = strip -d -R .comment $@
@@ -76,7 +76,14 @@ ARFLAGS_win64 = -out:$@
7676
ASFLAGS_mingw = -f win64
7777
ARFLAGS_mingw = cr $@
7878

79-
LDFLAGS_so = -Wl,-soname,$(soname)
79+
LDFLAGS_so = -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,-soname,$(soname)
80+
81+
ifeq ($(shell uname),Linux)
82+
ifeq ($(host_cpu),x86_64)
83+
CFLAGS_ = -fcf-protection=full
84+
LDFLAGS += -Wl,-z,ibt -Wl,-z,shstk -Wl,-z,cet-report=error
85+
endif
86+
endif
8087

8188
ifeq ($(arch),mingw)
8289
CC=x86_64-w64-mingw32-gcc

0 commit comments

Comments
 (0)