build: passing the "-z defs" linker flag to prevent undefined symbols

Undefined symbols are a bad thing in general because they can get
resolved in unexpected ways at runtime if multiple sources provide the
same symbol name. For example both glibc and libtirpc may provide XDR
symbols and we want to ensure that we resolve to libtirpc if that's what
we originally built against.

The toolchain maintainers thus strongly recommend that all applications
use the '-z defs' linker flag to prevent undefined symbols. This is
shortly becoming part of the default linker flags for RPMs. As an added
benefit this aligns Linux builds with Windows builds, where the linker
has never permitted undefined symbols.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé
2018-01-25 09:35:58 +00:00
parent 9e3c9af98a
commit a1f6030def
5 changed files with 60 additions and 16 deletions

View File

@@ -35,6 +35,7 @@ AM_CFLAGS = \
AM_LDFLAGS = \
$(RELRO_LDFLAGS) \
$(NO_INDIRECT_LDFLAGS) \
$(NO_UNDEFINED_LDFLAGS) \
$(NULL)
ICON_FILES = \