]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add -Wl,--export-dynamic to standard LDFLAGS if supported
authorOndřej Surý <ondrej@isc.org>
Wed, 27 Apr 2022 14:41:27 +0000 (16:41 +0200)
committerOndřej Surý <ondrej@isc.org>
Tue, 3 May 2022 19:13:33 +0000 (21:13 +0200)
From the ld man page:

  When creating a dynamically linked executable, using the -E option or
  the --export-dynamic option causes the linker to add all symbols to
  the dynamic symbol table.  The dynamic symbol table is the set of
  symbols which are visible from dynamic objects at run time.

This should allow the backtrace(3) to fully resolve the symbols when
creating backtrace on an assertion failure.

Makefile.top
configure.ac

index 68bbc1242dcb654e81197b4879fb7b82aa07c83f..62c5293c2c7555c54fd6c3ab100e7cb2a3510114 100644 (file)
@@ -11,7 +11,8 @@ AM_CPPFLAGS =                                 \
        -include $(top_builddir)/config.h       \
        -I$(srcdir)/include
 
-AM_LDFLAGS =
+AM_LDFLAGS =                                   \
+       $(STD_LDFLAGS)
 LDADD =
 
 if HOST_MACOS
index 9b29cb4901d2b232b86a2a5dd85b4a0f76024ef0..db46a9f83f3c8e25f62e9b6d6b7914d47c6d3b5a 100644 (file)
@@ -112,13 +112,15 @@ AS_IF([test "$enable_static" != "no" && test "$enable_developer" != "yes"],
       [AC_MSG_ERROR([Static linking is not supported as it disables dlopen() and certain security features (e.g. RELRO, ASLR)])])
 
 #
-# Set the default CFLAGS and CPPFLAGS
+# Set the default CFLAGS, CPPFLAGS, and LDFLAGS
 #
 STD_CFLAGS="-Wall -Wextra -Wwrite-strings -Wpointer-arith -Wno-missing-field-initializers -Wformat -Wshadow"
 
 # These should be always errors
 STD_CFLAGS="$STD_CFLAGS -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=format-security -Werror=parentheses -Werror=implicit -Werror=strict-prototypes -Werror=vla"
 
+STD_LDFLAGS=""
+
 # ... except in test code
 TEST_CFLAGS="-Wno-vla"
 
@@ -136,6 +138,9 @@ AX_CHECK_COMPILE_FLAG([-Werror -fno-delete-null-pointer-checks],
 AX_CHECK_COMPILE_FLAG([-fdiagnostics-show-option],
                      [STD_CFLAGS="$STD_CFLAGS -fdiagnostics-show-option"])
 
+AX_CHECK_LINK_FLAG([-Wl,--export-dynamic],
+                  [STD_LDFLAGS="$STD_LDFLAGS -Wl,--export-dynamic"])
+
 host_macos=no
 AS_CASE([$host],[*-darwin*],[host_macos=yes])
 AM_CONDITIONAL([HOST_MACOS], [test "$host_macos" = "yes"])
@@ -162,6 +167,7 @@ AS_IF([test "$enable_developer" = "yes"],
 AC_SUBST([DEVELOPER_MODE])
 AC_SUBST([STD_CFLAGS])
 AC_SUBST([STD_CPPFLAGS])
+AC_SUBST([STD_LDFLAGS])
 AC_SUBST([TEST_CFLAGS])
 
 # [pairwise: --enable-warn-error, --disable-warn-error]