Skip to content

Commit

Permalink
build: enable full read-only relocations and control flow integrity f…
Browse files Browse the repository at this point in the history
…or hardening check

Signed-off-by: Tomasz Kantecki <[email protected]>
  • Loading branch information
tkanteck authored and mdcornu committed Dec 18, 2023
1 parent 809f536 commit c183961
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 9 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@
Expand All @@ -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
Expand Down

0 comments on commit c183961

Please sign in to comment.