From 46e654d133922606991cf1ab74a224c9aad1e8ad Mon Sep 17 00:00:00 2001 From: Tomasz Kantecki Date: Wed, 3 Jan 2024 16:23:52 +0000 Subject: [PATCH] build: detect availability of -z now, relro and noexecstack linker options Signed-off-by: Tomasz Kantecki --- configure.ac | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index a0e059ed..ed321c90 100644 --- a/configure.ac +++ b/configure.ac @@ -79,6 +79,21 @@ 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 +305,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