diff --git a/configure.ac b/configure.ac index b8bcfbb60..c8d81e16c 100644 --- a/configure.ac +++ b/configure.ac @@ -199,7 +199,7 @@ AC_MSG_RESULT([$SHARED_LINK]) dnl -- Check if compiler/linker supports PIE and RELRO AC_TRY_CCFLAG([-pie], [HAVE_PIE], [], []) AC_SUBST(HAVE_PIE) -AC_TRY_LDFLAGS([-Wl,-z,relro,-z,now], [HAVE_FULL_RELRO], [], []) +AC_TRY_LDFLAGS([-Wl,-z,relro,-z,now,-z,pack-relative-relocs,--as-needed], [HAVE_FULL_RELRO], [], []) AC_SUBST(HAVE_FULL_RELRO) ################################################################################ diff --git a/daemons/lvmlockd/Makefile.in b/daemons/lvmlockd/Makefile.in index 7b8af8fe5..61dae4e9b 100644 --- a/daemons/lvmlockd/Makefile.in +++ b/daemons/lvmlockd/Makefile.in @@ -51,7 +51,8 @@ LDFLAGS += -L$(top_builddir)/libdaemon/server $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) LIBS += $(DAEMON_LIBS) $(PTHREAD_LIBS) ifneq (,$(firstword $(LIBSYSTEMD_LIBS))) - CFLAGS += $(LIBSYSTEMD_CFLAGS) -DUSE_SD_NOTIFY + DEFS += -DUSE_SD_NOTIFY + CFLAGS += $(LIBSYSTEMD_CFLAGS) LIBS += $(LIBSYSTEMD_LIBS) endif diff --git a/libdm/make.tmpl.in b/libdm/make.tmpl.in index 5c6b2160f..a4d4ca731 100644 --- a/libdm/make.tmpl.in +++ b/libdm/make.tmpl.in @@ -233,11 +233,16 @@ endif endif ifneq ("@STATIC_LINK@", "yes") +ifeq (,$(findstring relro,$(LDFLAGS))) +ifeq ("@HAVE_FULL_RELRO@", "yes") + LDFLAGS += -Wl,-z,relro,-z,now,-z,pack-relative-relocs,--as-needed +endif +endif + ifeq ("@HAVE_PIE@", "yes") ifeq ("@HAVE_FULL_RELRO@", "yes") EXTRA_EXEC_CFLAGS += -fPIE - EXTRA_EXEC_LDFLAGS += -Wl,-z,relro,-z,now -pie -fPIE - CLDFLAGS += -Wl,-z,relro + EXTRA_EXEC_LDFLAGS += -pie -fPIE endif endif endif diff --git a/make.tmpl.in b/make.tmpl.in index 238f690b9..a1c62513f 100644 --- a/make.tmpl.in +++ b/make.tmpl.in @@ -270,13 +270,16 @@ endif endif ifneq ("@STATIC_LINK@", "yes") -ifeq ("@HAVE_PIE@", "yes") +ifeq (,$(findstring relro,$(LDFLAGS))) ifeq ("@HAVE_FULL_RELRO@", "yes") - EXTRA_EXEC_CFLAGS += -fPIE - EXTRA_EXEC_LDFLAGS += -Wl,-z,relro,-z,now -pie -fPIE - CLDFLAGS += -Wl,-z,relro + LDFLAGS += -Wl,-z,relro,-z,now,-z,pack-relative-relocs,--as-needed endif endif + +ifeq ("@HAVE_PIE@", "yes") + EXTRA_EXEC_CFLAGS += -fPIE + EXTRA_EXEC_LDFLAGS += -pie -fPIE +endif endif #WFLAGS += -W -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers