diff --git a/make/autoconf/flags-ldflags.m4 b/make/autoconf/flags-ldflags.m4 index b63a8727a34..195c1d34159 100644 --- a/make/autoconf/flags-ldflags.m4 +++ b/make/autoconf/flags-ldflags.m4 @@ -60,7 +60,8 @@ AC_DEFUN([FLAGS_SETUP_LDFLAGS_HELPER], # Add -z,defs, to forbid undefined symbols in object files. # add -z,relro (mark relocations read only) for all libs # add -z,now ("full relro" - more of the Global Offset Table GOT is marked read only) - BASIC_LDFLAGS="-Wl,-z,defs -Wl,-z,relro -Wl,-z,now" + # add --no-as-needed to disable default --as-needed link flag on some GCC toolchains + BASIC_LDFLAGS="-Wl,-z,defs -Wl,-z,relro -Wl,-z,now -Wl,--no-as-needed" # Linux : remove unused code+data in link step if test "x$ENABLE_LINKTIME_GC" = xtrue; then if test "x$OPENJDK_TARGET_CPU" = xs390x; then