build: enable full read-only relocations and control flow integrity for hardening check

Signed-off-by: Tomasz Kantecki <tomasz.kantecki@intel.com>
This commit is contained in:
Tomasz Kantecki 2023-12-14 14:17:16 +00:00 committed by Marcel Cornu
parent 809f536265
commit c183961175
2 changed files with 18 additions and 2 deletions

View File

@ -285,9 +285,18 @@ my_CFLAGS="\
-Wshadow \
-Wstrict-prototypes \
-Wtype-limits \
-fstack-protector \
-D_FORTIFY_SOURCE=2 \
"
AC_SUBST([my_CFLAGS])
AM_LDFLAGS="\
-Wl,-z,noexecstack \
-Wl,-z,relro \
-Wl,-z,now \
"
AC_SUBST([AM_LDFLAGS])
AC_CONFIG_FILES([\
Makefile\
libisal.pc

View File

@ -57,7 +57,7 @@ DEBUG_yasm = -g dwarf2
DEBUG_nasm = -g
# Default arch= build options
CFLAGS_ = -Wall
CFLAGS_ = -Wall -Wchar-subscripts -Wformat-security -Wnested-externs -Wpointer-arith -Wshadow -Wstrict-prototypes -Wtype-limits -fstack-protector -D_FORTIFY_SOURCE=2
ASFLAGS_ = -f elf64
ARFLAGS_ = cr $@
STRIP_gcc = strip -d -R .comment $@
@ -76,7 +76,14 @@ ARFLAGS_win64 = -out:$@
ASFLAGS_mingw = -f win64
ARFLAGS_mingw = cr $@
LDFLAGS_so = -Wl,-soname,$(soname)
LDFLAGS_so = -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,-soname,$(soname)
ifeq ($(shell uname),Linux)
ifeq ($(host_cpu),x86_64)
CFLAGS_ = -fcf-protection=full
LDFLAGS += -Wl,-z,ibt -Wl,-z,shstk -Wl,-z,cet-report=error
endif
endif
ifeq ($(arch),mingw)
CC=x86_64-w64-mingw32-gcc