* PING: [PATCH] Use dlsym to check if libdl is needed for plugin
@ 2018-02-21 11:02 H.J. Lu
0 siblings, 0 replies; only message in thread
From: H.J. Lu @ 2018-02-21 11:02 UTC (permalink / raw)
Cc: GCC Patches
On Wed, Oct 18, 2017 at 5:25 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> config/plugins.m4 has
>
> if test "$plugins" = "yes"; then
> AC_SEARCH_LIBS([dlopen], [dl])
> fi
>
> Plugin uses dlsym, but libasan.so only intercepts dlopen, not dlsym:
>
> [hjl@gnu-tools-1 binutils-text]$ nm -D /lib64/libasan.so.4| grep " dl"
> 0000000000038580 W dlclose
> U dl_iterate_phdr
> 000000000004dc50 W dlopen
> U dlsym
> U dlvsym
> [hjl@gnu-tools-1 binutils-text]$
>
> Testing dlopen for libdl leads to false negative when -fsanitize=address
> is used. It results in link failure:
>
> ../bfd/.libs/libbfd.a(plugin.o): undefined reference to symbol 'dlsym@@GLIBC_2.16'
>
> dlsym should be used to check if libdl is needed for plugin.
>
> OK for master?
>
> H.J.
> ---
> bfd/
>
> PR gas/22318
> * configure: Regenerated.
>
> binutils/
>
> PR gas/22318
> * configure: Regenerated.
>
> config/
>
> * plugins.m4 (AC_PLUGINS): Use dlsym to check if libdl is needed.
>
> gas/
>
> PR gas/22318
> * configure: Regenerated.
>
> gprof/
>
> PR gas/22318
> * configure: Regenerated.
>
> ld/
>
> PR gas/22318
> * configure: Regenerated.
> ---
> bfd/configure | 24 ++++++++++++------------
> binutils/configure | 24 ++++++++++++------------
> config/plugins.m4 | 2 +-
> gas/configure | 24 ++++++++++++------------
> gprof/configure | 24 ++++++++++++------------
> ld/configure | 24 ++++++++++++------------
> 6 files changed, 61 insertions(+), 61 deletions(-)
>
> diff --git a/bfd/configure b/bfd/configure
> index 32ee062e80..f019a61fb0 100755
> --- a/bfd/configure
> +++ b/bfd/configure
> @@ -11826,9 +11826,9 @@ else
> fi
>
> if test "$plugins" = "yes"; then
> - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5
> -$as_echo_n "checking for library containing dlopen... " >&6; }
> -if test "${ac_cv_search_dlopen+set}" = set; then :
> + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlsym" >&5
> +$as_echo_n "checking for library containing dlsym... " >&6; }
> +if test "${ac_cv_search_dlsym+set}" = set; then :
> $as_echo_n "(cached) " >&6
> else
> ac_func_search_save_LIBS=$LIBS
> @@ -11841,11 +11841,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> #ifdef __cplusplus
> extern "C"
> #endif
> -char dlopen ();
> +char dlsym ();
> int
> main ()
> {
> -return dlopen ();
> +return dlsym ();
> ;
> return 0;
> }
> @@ -11858,25 +11858,25 @@ for ac_lib in '' dl; do
> LIBS="-l$ac_lib $ac_func_search_save_LIBS"
> fi
> if ac_fn_c_try_link "$LINENO"; then :
> - ac_cv_search_dlopen=$ac_res
> + ac_cv_search_dlsym=$ac_res
> fi
> rm -f core conftest.err conftest.$ac_objext \
> conftest$ac_exeext
> - if test "${ac_cv_search_dlopen+set}" = set; then :
> + if test "${ac_cv_search_dlsym+set}" = set; then :
> break
> fi
> done
> -if test "${ac_cv_search_dlopen+set}" = set; then :
> +if test "${ac_cv_search_dlsym+set}" = set; then :
>
> else
> - ac_cv_search_dlopen=no
> + ac_cv_search_dlsym=no
> fi
> rm conftest.$ac_ext
> LIBS=$ac_func_search_save_LIBS
> fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5
> -$as_echo "$ac_cv_search_dlopen" >&6; }
> -ac_res=$ac_cv_search_dlopen
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlsym" >&5
> +$as_echo "$ac_cv_search_dlsym" >&6; }
> +ac_res=$ac_cv_search_dlsym
> if test "$ac_res" != no; then :
> test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
>
> diff --git a/binutils/configure b/binutils/configure
> index 22e1b1736e..9691ec23f0 100755
> --- a/binutils/configure
> +++ b/binutils/configure
> @@ -11622,9 +11622,9 @@ else
> fi
>
> if test "$plugins" = "yes"; then
> - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5
> -$as_echo_n "checking for library containing dlopen... " >&6; }
> -if test "${ac_cv_search_dlopen+set}" = set; then :
> + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlsym" >&5
> +$as_echo_n "checking for library containing dlsym... " >&6; }
> +if test "${ac_cv_search_dlsym+set}" = set; then :
> $as_echo_n "(cached) " >&6
> else
> ac_func_search_save_LIBS=$LIBS
> @@ -11637,11 +11637,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> #ifdef __cplusplus
> extern "C"
> #endif
> -char dlopen ();
> +char dlsym ();
> int
> main ()
> {
> -return dlopen ();
> +return dlsym ();
> ;
> return 0;
> }
> @@ -11654,25 +11654,25 @@ for ac_lib in '' dl; do
> LIBS="-l$ac_lib $ac_func_search_save_LIBS"
> fi
> if ac_fn_c_try_link "$LINENO"; then :
> - ac_cv_search_dlopen=$ac_res
> + ac_cv_search_dlsym=$ac_res
> fi
> rm -f core conftest.err conftest.$ac_objext \
> conftest$ac_exeext
> - if test "${ac_cv_search_dlopen+set}" = set; then :
> + if test "${ac_cv_search_dlsym+set}" = set; then :
> break
> fi
> done
> -if test "${ac_cv_search_dlopen+set}" = set; then :
> +if test "${ac_cv_search_dlsym+set}" = set; then :
>
> else
> - ac_cv_search_dlopen=no
> + ac_cv_search_dlsym=no
> fi
> rm conftest.$ac_ext
> LIBS=$ac_func_search_save_LIBS
> fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5
> -$as_echo "$ac_cv_search_dlopen" >&6; }
> -ac_res=$ac_cv_search_dlopen
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlsym" >&5
> +$as_echo "$ac_cv_search_dlsym" >&6; }
> +ac_res=$ac_cv_search_dlsym
> if test "$ac_res" != no; then :
> test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
>
> diff --git a/config/plugins.m4 b/config/plugins.m4
> index 513c690e1b..c6acebc1ca 100644
> --- a/config/plugins.m4
> +++ b/config/plugins.m4
> @@ -16,6 +16,6 @@ AC_DEFUN([AC_PLUGINS],
> [plugins=$maybe_plugins]
> )
> if test "$plugins" = "yes"; then
> - AC_SEARCH_LIBS([dlopen], [dl])
> + AC_SEARCH_LIBS([dlsym], [dl])
> fi
> ])
> diff --git a/gas/configure b/gas/configure
> index 93afb20c8f..b4dcc12e22 100755
> --- a/gas/configure
> +++ b/gas/configure
> @@ -11383,9 +11383,9 @@ else
> fi
>
> if test "$plugins" = "yes"; then
> - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5
> -$as_echo_n "checking for library containing dlopen... " >&6; }
> -if test "${ac_cv_search_dlopen+set}" = set; then :
> + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlsym" >&5
> +$as_echo_n "checking for library containing dlsym... " >&6; }
> +if test "${ac_cv_search_dlsym+set}" = set; then :
> $as_echo_n "(cached) " >&6
> else
> ac_func_search_save_LIBS=$LIBS
> @@ -11398,11 +11398,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> #ifdef __cplusplus
> extern "C"
> #endif
> -char dlopen ();
> +char dlsym ();
> int
> main ()
> {
> -return dlopen ();
> +return dlsym ();
> ;
> return 0;
> }
> @@ -11415,25 +11415,25 @@ for ac_lib in '' dl; do
> LIBS="-l$ac_lib $ac_func_search_save_LIBS"
> fi
> if ac_fn_c_try_link "$LINENO"; then :
> - ac_cv_search_dlopen=$ac_res
> + ac_cv_search_dlsym=$ac_res
> fi
> rm -f core conftest.err conftest.$ac_objext \
> conftest$ac_exeext
> - if test "${ac_cv_search_dlopen+set}" = set; then :
> + if test "${ac_cv_search_dlsym+set}" = set; then :
> break
> fi
> done
> -if test "${ac_cv_search_dlopen+set}" = set; then :
> +if test "${ac_cv_search_dlsym+set}" = set; then :
>
> else
> - ac_cv_search_dlopen=no
> + ac_cv_search_dlsym=no
> fi
> rm conftest.$ac_ext
> LIBS=$ac_func_search_save_LIBS
> fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5
> -$as_echo "$ac_cv_search_dlopen" >&6; }
> -ac_res=$ac_cv_search_dlopen
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlsym" >&5
> +$as_echo "$ac_cv_search_dlsym" >&6; }
> +ac_res=$ac_cv_search_dlsym
> if test "$ac_res" != no; then :
> test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
>
> diff --git a/gprof/configure b/gprof/configure
> index e71fe8b9e4..a4d0ed360a 100755
> --- a/gprof/configure
> +++ b/gprof/configure
> @@ -11298,9 +11298,9 @@ else
> fi
>
> if test "$plugins" = "yes"; then
> - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5
> -$as_echo_n "checking for library containing dlopen... " >&6; }
> -if test "${ac_cv_search_dlopen+set}" = set; then :
> + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlsym" >&5
> +$as_echo_n "checking for library containing dlsym... " >&6; }
> +if test "${ac_cv_search_dlsym+set}" = set; then :
> $as_echo_n "(cached) " >&6
> else
> ac_func_search_save_LIBS=$LIBS
> @@ -11313,11 +11313,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> #ifdef __cplusplus
> extern "C"
> #endif
> -char dlopen ();
> +char dlsym ();
> int
> main ()
> {
> -return dlopen ();
> +return dlsym ();
> ;
> return 0;
> }
> @@ -11330,25 +11330,25 @@ for ac_lib in '' dl; do
> LIBS="-l$ac_lib $ac_func_search_save_LIBS"
> fi
> if ac_fn_c_try_link "$LINENO"; then :
> - ac_cv_search_dlopen=$ac_res
> + ac_cv_search_dlsym=$ac_res
> fi
> rm -f core conftest.err conftest.$ac_objext \
> conftest$ac_exeext
> - if test "${ac_cv_search_dlopen+set}" = set; then :
> + if test "${ac_cv_search_dlsym+set}" = set; then :
> break
> fi
> done
> -if test "${ac_cv_search_dlopen+set}" = set; then :
> +if test "${ac_cv_search_dlsym+set}" = set; then :
>
> else
> - ac_cv_search_dlopen=no
> + ac_cv_search_dlsym=no
> fi
> rm conftest.$ac_ext
> LIBS=$ac_func_search_save_LIBS
> fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5
> -$as_echo "$ac_cv_search_dlopen" >&6; }
> -ac_res=$ac_cv_search_dlopen
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlsym" >&5
> +$as_echo "$ac_cv_search_dlsym" >&6; }
> +ac_res=$ac_cv_search_dlsym
> if test "$ac_res" != no; then :
> test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
>
> diff --git a/ld/configure b/ld/configure
> index 473b6c0562..8b74a03cd8 100755
> --- a/ld/configure
> +++ b/ld/configure
> @@ -15137,9 +15137,9 @@ else
> fi
>
> if test "$plugins" = "yes"; then
> - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5
> -$as_echo_n "checking for library containing dlopen... " >&6; }
> -if test "${ac_cv_search_dlopen+set}" = set; then :
> + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlsym" >&5
> +$as_echo_n "checking for library containing dlsym... " >&6; }
> +if test "${ac_cv_search_dlsym+set}" = set; then :
> $as_echo_n "(cached) " >&6
> else
> ac_func_search_save_LIBS=$LIBS
> @@ -15152,11 +15152,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> #ifdef __cplusplus
> extern "C"
> #endif
> -char dlopen ();
> +char dlsym ();
> int
> main ()
> {
> -return dlopen ();
> +return dlsym ();
> ;
> return 0;
> }
> @@ -15169,25 +15169,25 @@ for ac_lib in '' dl; do
> LIBS="-l$ac_lib $ac_func_search_save_LIBS"
> fi
> if ac_fn_c_try_link "$LINENO"; then :
> - ac_cv_search_dlopen=$ac_res
> + ac_cv_search_dlsym=$ac_res
> fi
> rm -f core conftest.err conftest.$ac_objext \
> conftest$ac_exeext
> - if test "${ac_cv_search_dlopen+set}" = set; then :
> + if test "${ac_cv_search_dlsym+set}" = set; then :
> break
> fi
> done
> -if test "${ac_cv_search_dlopen+set}" = set; then :
> +if test "${ac_cv_search_dlsym+set}" = set; then :
>
> else
> - ac_cv_search_dlopen=no
> + ac_cv_search_dlsym=no
> fi
> rm conftest.$ac_ext
> LIBS=$ac_func_search_save_LIBS
> fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5
> -$as_echo "$ac_cv_search_dlopen" >&6; }
> -ac_res=$ac_cv_search_dlopen
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlsym" >&5
> +$as_echo "$ac_cv_search_dlsym" >&6; }
> +ac_res=$ac_cv_search_dlsym
> if test "$ac_res" != no; then :
> test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
>
> --
> 2.13.6
>
--
H.J.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-02-21 11:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-21 11:02 PING: [PATCH] Use dlsym to check if libdl is needed for plugin H.J. Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).