1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

configure.ac: update ldflags args

Attach -Wl,-z,relro,-z,now,-z,pack-relative-relocs,--as-needed
to LDFLAGS, but only if LDFLAGS already doesn't contain 'relro'
(so it's not given repeatedly).

Also start to use -z,now linkage also when building libraries
with default compilation - this avoid calling symbol resolver
while library function are using function needing resolving.

Note: Fedora or RHEL rpm building is using:
CFLAGS=$(rpm --eval %{build_cflags})
LDFLAGS=$(rpm --eval %{build_ldflags})

Also split -DUSE_SD_NOTIFY into DEFS from CFLAGS.
This commit is contained in:
Zdenek Kabelac 2024-04-23 23:30:35 +02:00
parent f022da9e5f
commit 078445658c
4 changed files with 17 additions and 8 deletions

View File

@ -199,7 +199,7 @@ AC_MSG_RESULT([$SHARED_LINK])
dnl -- Check if compiler/linker supports PIE and RELRO dnl -- Check if compiler/linker supports PIE and RELRO
AC_TRY_CCFLAG([-pie], [HAVE_PIE], [], []) AC_TRY_CCFLAG([-pie], [HAVE_PIE], [], [])
AC_SUBST(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) AC_SUBST(HAVE_FULL_RELRO)
################################################################################ ################################################################################

View File

@ -51,7 +51,8 @@ LDFLAGS += -L$(top_builddir)/libdaemon/server $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS)
LIBS += $(DAEMON_LIBS) $(PTHREAD_LIBS) LIBS += $(DAEMON_LIBS) $(PTHREAD_LIBS)
ifneq (,$(firstword $(LIBSYSTEMD_LIBS))) ifneq (,$(firstword $(LIBSYSTEMD_LIBS)))
CFLAGS += $(LIBSYSTEMD_CFLAGS) -DUSE_SD_NOTIFY DEFS += -DUSE_SD_NOTIFY
CFLAGS += $(LIBSYSTEMD_CFLAGS)
LIBS += $(LIBSYSTEMD_LIBS) LIBS += $(LIBSYSTEMD_LIBS)
endif endif

View File

@ -233,11 +233,16 @@ endif
endif endif
ifneq ("@STATIC_LINK@", "yes") 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_PIE@", "yes")
ifeq ("@HAVE_FULL_RELRO@", "yes") ifeq ("@HAVE_FULL_RELRO@", "yes")
EXTRA_EXEC_CFLAGS += -fPIE EXTRA_EXEC_CFLAGS += -fPIE
EXTRA_EXEC_LDFLAGS += -Wl,-z,relro,-z,now -pie -fPIE EXTRA_EXEC_LDFLAGS += -pie -fPIE
CLDFLAGS += -Wl,-z,relro
endif endif
endif endif
endif endif

View File

@ -270,13 +270,16 @@ endif
endif endif
ifneq ("@STATIC_LINK@", "yes") ifneq ("@STATIC_LINK@", "yes")
ifeq ("@HAVE_PIE@", "yes") ifeq (,$(findstring relro,$(LDFLAGS)))
ifeq ("@HAVE_FULL_RELRO@", "yes") ifeq ("@HAVE_FULL_RELRO@", "yes")
EXTRA_EXEC_CFLAGS += -fPIE LDFLAGS += -Wl,-z,relro,-z,now,-z,pack-relative-relocs,--as-needed
EXTRA_EXEC_LDFLAGS += -Wl,-z,relro,-z,now -pie -fPIE
CLDFLAGS += -Wl,-z,relro
endif endif
endif endif
ifeq ("@HAVE_PIE@", "yes")
EXTRA_EXEC_CFLAGS += -fPIE
EXTRA_EXEC_LDFLAGS += -pie -fPIE
endif
endif endif
#WFLAGS += -W -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers #WFLAGS += -W -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers