mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-22 01:49:11 +00:00
Try to link a simple shared object with -Wl,--no-undefined.
This only works for gcc-style compilers, which should not be a problem. The source uses environ (FreeBSD) and errno (OpenBSD).
This commit is contained in:
parent
0010c98613
commit
f65a51afdf
65
configure
vendored
65
configure
vendored
@ -19828,54 +19828,51 @@ fi
|
|||||||
# but is incompatible with the sanitizers/fuzzers.
|
# but is incompatible with the sanitizers/fuzzers.
|
||||||
# We must set this *before* the library tests.
|
# We must set this *before* the library tests.
|
||||||
#
|
#
|
||||||
if test X"${enable_sanitizer}{enable_fuzzer}" = X"nono"; then
|
if test -n "$GCC" -a X"${enable_sanitizer}${enable_fuzzer}" = X"nono"; then
|
||||||
case "$host_os" in
|
# On FreeBSD and Dragonfly, environ is filled in by the dynamic loader
|
||||||
freebsd*|dragonfly*|openbsd*)
|
# so -Wl,--no-undefined causes a link error when environ is used.
|
||||||
# On FreeBSD and Dragonfly, environ is filled in by the
|
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=263265
|
||||||
# dynamic loader so we cannot use -Wl,--no-undefined.
|
# We use errno because OpenBSD shared libraries don't explicitly
|
||||||
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=263265
|
# link with libc, which can result in undefined reference errors.
|
||||||
# OpenBSD shared libraries don't link explicitly with libc
|
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the linker accepts -Wl,--no-undefined" >&5
|
||||||
# which results in undefined references errors.
|
printf %s "checking the linker accepts -Wl,--no-undefined... " >&6; }
|
||||||
# Ideally we would link a shared object with -Wl,--no-undefined
|
if test ${sudo_cv_var_ld___no_undefined+y}
|
||||||
# and see if it works but this is not easy in a libtool world.
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the linker accepts -Wl,--no-undefined" >&5
|
|
||||||
printf %s "checking whether the linker accepts -Wl,--no-undefined... " >&6; }
|
|
||||||
if test ${ax_cv_check_ldflags___Wl___no_undefined+y}
|
|
||||||
then :
|
then :
|
||||||
printf %s "(cached) " >&6
|
printf %s "(cached) " >&6
|
||||||
else case e in #(
|
else case e in #(
|
||||||
e)
|
e)
|
||||||
ax_check_save_flags=$LDFLAGS
|
sudo_cv_var_ld___no_undefined=no
|
||||||
LDFLAGS="$LDFLAGS -Wl,--no-undefined"
|
_CFLAGS="$CFLAGS"
|
||||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
CFLAGS="$CFLAGS $lt_prog_compiler_pic"
|
||||||
|
_LDFLAGS="$LDFLAGS"
|
||||||
|
LDFLAGS="$LDFLAGS $lt_prog_compiler_pic -shared -Wl,--no-undefined"
|
||||||
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
/* end confdefs.h. */
|
/* end confdefs.h. */
|
||||||
|
#include <errno.h>
|
||||||
|
extern char **environ;
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
|
int ret = ((long)environ & 0xff) + errno; return ret;
|
||||||
;
|
;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
_ACEOF
|
_ACEOF
|
||||||
if ac_fn_c_try_link "$LINENO"
|
if ac_fn_c_try_link "$LINENO"
|
||||||
then :
|
then :
|
||||||
ax_cv_check_ldflags___Wl___no_undefined=yes
|
sudo_cv_var_ld___no_undefined=yes
|
||||||
else case e in #(
|
|
||||||
e) ax_cv_check_ldflags___Wl___no_undefined=no ;;
|
|
||||||
esac
|
|
||||||
fi
|
fi
|
||||||
rm -f core conftest.err conftest.$ac_objext conftest.beam \
|
rm -f core conftest.err conftest.$ac_objext conftest.beam \
|
||||||
conftest$ac_exeext conftest.$ac_ext
|
conftest$ac_exeext conftest.$ac_ext
|
||||||
LDFLAGS=$ax_check_save_flags ;;
|
CFLAGS="$_CFLAGS"
|
||||||
|
LDFLAGS="$_LDFLAGS"
|
||||||
|
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_ldflags___Wl___no_undefined" >&5
|
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $sudo_cv_var_ld___no_undefined" >&5
|
||||||
printf "%s\n" "$ax_cv_check_ldflags___Wl___no_undefined" >&6; }
|
printf "%s\n" "$sudo_cv_var_ld___no_undefined" >&6; }
|
||||||
if test x"$ax_cv_check_ldflags___Wl___no_undefined" = xyes
|
if test "$sudo_cv_var_ld___no_undefined" = "yes"; then
|
||||||
then :
|
|
||||||
|
|
||||||
if test ${LDFLAGS+y}
|
if test ${LDFLAGS+y}
|
||||||
then :
|
then :
|
||||||
@ -19910,13 +19907,7 @@ else case e in #(
|
|||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else case e in #(
|
fi
|
||||||
e) : ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -32523,7 +32514,7 @@ else case e in #(
|
|||||||
_CFLAGS="$CFLAGS"
|
_CFLAGS="$CFLAGS"
|
||||||
CFLAGS="$CFLAGS $lt_prog_compiler_pic"
|
CFLAGS="$CFLAGS $lt_prog_compiler_pic"
|
||||||
_LDFLAGS="$LDFLAGS"
|
_LDFLAGS="$LDFLAGS"
|
||||||
LDFLAGS="$LDFLAGS -fpic -shared -Wl,--version-script,./conftest.map"
|
LDFLAGS="$LDFLAGS $lt_prog_compiler_pic -shared -Wl,--version-script,./conftest.map"
|
||||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
/* end confdefs.h. */
|
/* end confdefs.h. */
|
||||||
int foo;
|
int foo;
|
||||||
|
45
configure.ac
45
configure.ac
@ -2455,21 +2455,30 @@ AC_SYS_YEAR2038
|
|||||||
# but is incompatible with the sanitizers/fuzzers.
|
# but is incompatible with the sanitizers/fuzzers.
|
||||||
# We must set this *before* the library tests.
|
# We must set this *before* the library tests.
|
||||||
#
|
#
|
||||||
if test X"${enable_sanitizer}{enable_fuzzer}" = X"nono"; then
|
if test -n "$GCC" -a X"${enable_sanitizer}${enable_fuzzer}" = X"nono"; then
|
||||||
case "$host_os" in
|
# On FreeBSD and Dragonfly, environ is filled in by the dynamic loader
|
||||||
freebsd*|dragonfly*|openbsd*)
|
# so -Wl,--no-undefined causes a link error when environ is used.
|
||||||
# On FreeBSD and Dragonfly, environ is filled in by the
|
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=263265
|
||||||
# dynamic loader so we cannot use -Wl,--no-undefined.
|
# We use errno because OpenBSD shared libraries don't explicitly
|
||||||
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=263265
|
# link with libc, which can result in undefined reference errors.
|
||||||
# OpenBSD shared libraries don't link explicitly with libc
|
AC_CACHE_CHECK([the linker accepts -Wl,--no-undefined],
|
||||||
# which results in undefined references errors.
|
[sudo_cv_var_ld___no_undefined],
|
||||||
# Ideally we would link a shared object with -Wl,--no-undefined
|
[
|
||||||
# and see if it works but this is not easy in a libtool world.
|
sudo_cv_var_ld___no_undefined=no
|
||||||
;;
|
_CFLAGS="$CFLAGS"
|
||||||
*)
|
CFLAGS="$CFLAGS $lt_prog_compiler_pic"
|
||||||
AX_CHECK_LINK_FLAG([-Wl,--no-undefined], [AX_APPEND_FLAG([-Wl,--no-undefined], [LDFLAGS])])
|
_LDFLAGS="$LDFLAGS"
|
||||||
;;
|
LDFLAGS="$LDFLAGS $lt_prog_compiler_pic -shared -Wl,--no-undefined"
|
||||||
esac
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <errno.h>
|
||||||
|
extern char **environ;]], [[int ret = ((long)environ & 0xff) + errno; return ret;]])],
|
||||||
|
[sudo_cv_var_ld___no_undefined=yes])
|
||||||
|
CFLAGS="$_CFLAGS"
|
||||||
|
LDFLAGS="$_LDFLAGS"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
if test "$sudo_cv_var_ld___no_undefined" = "yes"; then
|
||||||
|
AX_APPEND_FLAG([-Wl,--no-undefined], [LDFLAGS])
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -2482,12 +2491,12 @@ case "$host_os" in
|
|||||||
hpux*)
|
hpux*)
|
||||||
AC_CACHE_CHECK([whether sys/socket.h needs _XOPEN_SOURCE_EXTENDED for MSG_WAITALL], [sudo_cv_xopen_source_extended],
|
AC_CACHE_CHECK([whether sys/socket.h needs _XOPEN_SOURCE_EXTENDED for MSG_WAITALL], [sudo_cv_xopen_source_extended],
|
||||||
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
|
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
|
||||||
# include <sys/socket.h>], [int a = MSG_WAITALL; return a;])],
|
[# include <sys/socket.h>]], [[int a = MSG_WAITALL; return a;]])],
|
||||||
[sudo_cv_xopen_source_extended=no], [
|
[sudo_cv_xopen_source_extended=no], [
|
||||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#define _XOPEN_SOURCE_EXTENDED
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#define _XOPEN_SOURCE_EXTENDED
|
||||||
AC_INCLUDES_DEFAULT
|
AC_INCLUDES_DEFAULT
|
||||||
# include <sys/socket.h>
|
[# include <sys/socket.h>
|
||||||
# include <net/if.h>], [int a = MSG_WAITALL; return a;])],
|
# include <net/if.h>]], [[int a = MSG_WAITALL; return a;]])],
|
||||||
[sudo_cv_xopen_source_extended=yes],
|
[sudo_cv_xopen_source_extended=yes],
|
||||||
[sudo_cv_xopen_source_extended=error])
|
[sudo_cv_xopen_source_extended=error])
|
||||||
])])
|
])])
|
||||||
|
@ -71,7 +71,7 @@ AC_DEFUN([SUDO_SYMBOL_VISIBILITY], [
|
|||||||
_CFLAGS="$CFLAGS"
|
_CFLAGS="$CFLAGS"
|
||||||
CFLAGS="$CFLAGS $lt_prog_compiler_pic"
|
CFLAGS="$CFLAGS $lt_prog_compiler_pic"
|
||||||
_LDFLAGS="$LDFLAGS"
|
_LDFLAGS="$LDFLAGS"
|
||||||
LDFLAGS="$LDFLAGS -fpic -shared -Wl,--version-script,./conftest.map"
|
LDFLAGS="$LDFLAGS $lt_prog_compiler_pic -shared -Wl,--version-script,./conftest.map"
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[int foo;]], [[]])],
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[int foo;]], [[]])],
|
||||||
[sudo_cv_var_gnu_ld_anon_map=yes])
|
[sudo_cv_var_gnu_ld_anon_map=yes])
|
||||||
CFLAGS="$_CFLAGS"
|
CFLAGS="$_CFLAGS"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user