build: detect availability of -z now, relro and noexecstack linker options

Signed-off-by: Tomasz Kantecki <tomasz.kantecki@intel.com>
This commit is contained in:
Tomasz Kantecki 2024-01-03 16:23:52 +00:00 committed by Pablo de Lara
parent 71575ae434
commit 75af1c4d4e

View File

@ -79,6 +79,22 @@ AS_IF([test "x$intel_cet_enabled" = "xyes"], [
AC_DEFINE(INTEL_CET_ENABLED, [1], [Intel CET enabled.])
])
# check if LD -z options are supported
LDFLAGS="\
-Wl,-z,noexecstack \
-Wl,-z,relro \
-Wl,-z,now \
"
AC_MSG_CHECKING([if $LD supports $LDFLAGS])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
int main(int argc, char **argv)
{
return 0;
}]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
LDFLAGS=""]
)
# Pick an assembler yasm or nasm
if test x"$AS" = x""; then
@ -290,13 +306,6 @@ my_CFLAGS="\
"
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