Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

RTLD_GLOBAL test



-----BEGIN PGP SIGNED MESSAGE-----

This patch adds an autoconf test to see if symbols from loaded modules
are available directly to subsequently loaded modules (i.e., if we have
the RTLD_GLOBAL functionality).  On systems where this is not the case,
such as SunOS 4, the comp1 module is linked in to the main zsh executable
by default.

 -zefram

 *** aczsh.m4	1997/03/23 05:09:18	1.1
 --- aczsh.m4	1997/03/23 21:08:14
 ***************
 *** 79,81 ****
 --- 79,132 ----
       AC_DEFINE(DYNAMIC_NAME_CLASH_OK)
   fi
   ])
 + 
 + AC_DEFUN(zsh_SYS_DYNAMIC_GLOBAL,
 + [AC_CACHE_CHECK([for working RTLD_GLOBAL],
 + zsh_cv_sys_dynamic_rtld_global,
 + [if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then
 +     us=_
 + else
 +     us=
 + fi
 + echo 'int fred () { return 42; }' > conftest1.c
 + echo 'extern int fred(); int barney () { return fred() + 27; }' > conftest2.c
 + if $CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&5 2>&5 &&
 + $DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o 1>&5 2>&5 &&
 + $CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&5 2>&5 &&
 + $DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o 1>&5 2>&5; then
 +     AC_TRY_RUN([
 + #ifdef HAVE_DLFCN_H
 + #include <dlfcn.h>
 + #else
 + #include <sys/types.h>
 + #include <nlist.h>
 + #include <link.h>
 + #endif
 + #ifndef RTLD_LAZY
 + #define RTLD_LAZY 1
 + #endif
 + #ifndef RTLD_GLOBAL
 + #define RTLD_GLOBAL 0
 + #endif
 + 
 + main()
 + {
 +     void *handle;
 +     int (*barneysym)();
 +     handle = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
 +     if(!handle) exit(1);
 +     handle = dlopen("./conftest2.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
 +     if(!handle) exit(1);
 +     barneysym = (int (*)()) dlsym(handle, "${us}barney");
 +     if(!barneysym) exit(1);
 +     exit((*barneysym)() != 69);
 + }
 + ], [zsh_cv_sys_dynamic_rtld_global=yes],
 + [zsh_cv_sys_dynamic_rtld_global=no],
 + [zsh_cv_sys_dynamic_rtld_global=no]
 + )
 + else
 +     zsh_cv_sys_dynamic_rtld_global=no
 + fi
 + ])
 + ])
 *** configure.in	1997/03/23 05:09:18	1.32
 --- configure.in	1997/03/23 20:56:00
 ***************
 *** 888,896 ****
 --- 888,900 ----
   
   if test "x$dynamic" = xyes; then
     zsh_SYS_DYNAMIC_CLASH
 +   zsh_SYS_DYNAMIC_GLOBAL
 +   RTLD_GLOBAL_OK=$zsh_cv_sys_dynamic_rtld_global
     case "$host_os" in
       sysv4*|esix*)  L=L LIBS="$LIBS -L. -lzsh";;
     esac
 + else
 +   RTLD_GLOBAL_OK=no
   fi
   
   if test "x$dynamic" = xyes; then
 ***************
 *** 908,913 ****
 --- 912,918 ----
   AC_SUBST(DLLDFLAGS)dnl
   AC_SUBST(EXTRA_LDFLAGS)dnl
   AC_SUBST(L)dnl
 + AC_SUBST(RTLD_GLOBAL_OK)dnl
   
   AC_OUTPUT(Makefile Src/Makefile Src/Zle/Makefile Src/Modules/Makefile \
   Doc/Makefile Etc/Makefile Misc/Makefile Util/Makefile Functions/Makefile \
 *** Src/Makefile.in	1997/03/20 13:52:10	1.37
 --- Src/Makefile.in	1997/03/23 21:11:13
 ***************
 *** 225,231 ****
   	@echo "Creating \`$@'."
   	@( \
   	    binmods=`sed 's/^/ /;s/$$/ /' $(MODBINS)`; \
 ! 	    sed='/^[^:>]*>[^:>]*$$/{s/>.*//;p;}'; \
   	    xmods=`sed -n $(CFSED) -e "$$sed" $(XMODCF)`; \
   	    for mod in $$xmods; do \
   		case $$binmods in \
 --- 225,231 ----
   	@echo "Creating \`$@'."
   	@( \
   	    binmods=`sed 's/^/ /;s/$$/ /' $(MODBINS)`; \
 ! 	    sed='/^[^:>!]*[>!][^:>!]*$$/{s/[>!].*//;p;}'; \
   	    xmods=`sed -n $(CFSED) -e "$$sed" $(XMODCF)`; \
   	    for mod in $$xmods; do \
   		case $$binmods in \
 ***************
 *** 244,250 ****
   
   $(MODBINS):
   	if test @D@ = N; then \
 ! 	    sed -n $(CFSED) -e '/^[^:>]*>[^:>]*$$/{s/>.*//;p;}' $(XMODCF) > $@; \
   	else \
   	    echo > $@; \
   	fi
 --- 244,252 ----
   
   $(MODBINS):
   	if test @D@ = N; then \
 ! 	    sed -n $(CFSED) -e '/^[^:>!]*[>!][^:>!]*$$/{s/[>!].*//;p;}' $(XMODCF) > $@; \
 ! 	elif test @RTLD_GLOBAL_OK@ != yes; then \
 ! 	    sed -n $(CFSED) -e '/^[^:>!]*![^:>!]*$$/{s/!.*//;p;}' $(XMODCF) > $@; \
   	else \
   	    echo > $@; \
   	fi
 *** Src/mkbltnmlst.sh	1997/03/20 13:52:10	1.6
 --- Src/mkbltnmlst.sh	1997/03/23 21:05:45
 ***************
 *** 11,18 ****
   MODBINS=${MODBINS-modules-bltin}
   XMODCF=${XMODCF-$srcdir/xmods.conf}
   binmods=`sed 's/^/ /;s/$/ /' $MODBINS`
 ! sed='/^[^:>]*>[^:>]*$/{
 !     s/>.*//
       p
   }'
   xmods=`sed -n $CFSED -e "$sed" $XMODCF`
 --- 11,18 ----
   MODBINS=${MODBINS-modules-bltin}
   XMODCF=${XMODCF-$srcdir/xmods.conf}
   binmods=`sed 's/^/ /;s/$/ /' $MODBINS`
 ! sed='/^[^:>!]*[>!][^:>!]*$/{
 !     s/[>!].*//
       p
   }'
   xmods=`sed -n $CFSED -e "$sed" $XMODCF`
 ***************
 *** 23,37 ****
       case $binmods in
   	*" $mod "*) ;;
   	*)  echo "/* non-linked-in known module \`$mod' */"
 ! 	    sed='/^ *'$mod' *>[^:>]*$/{
 !                     s/.*>//
                       p
                    }'
   	    bins=`sed -n $CFSED -e "$sed" $XMODCF`
   	    for bin in $bins; do
   		echo "    add_autobin(\"$bin\", \"$mod\");"
   	    done
 ! 	    sed='/^ *'$mod' *:[^:>]*$/{
                        s/.*://
                        p
                    }'
 --- 23,37 ----
       case $binmods in
   	*" $mod "*) ;;
   	*)  echo "/* non-linked-in known module \`$mod' */"
 ! 	    sed='/^ *'$mod' *[>!][^:>!]*$/{
 !                     s/.*[>!]//
                       p
                    }'
   	    bins=`sed -n $CFSED -e "$sed" $XMODCF`
   	    for bin in $bins; do
   		echo "    add_autobin(\"$bin\", \"$mod\");"
   	    done
 ! 	    sed='/^ *'$mod' *:[^:>!]*$/{
                        s/.*://
                        p
                    }'
 ***************
 *** 50,56 ****
   donemods=" "
   for mod in $binmods; do
       echo "/* linked-in module \`$mod' */"
 !     sed='/^ *'$mod' *:[^:>]*$/{
                s/.*://
                p
            }'
 --- 50,56 ----
   donemods=" "
   for mod in $binmods; do
       echo "/* linked-in module \`$mod' */"
 !     sed='/^ *'$mod' *:[^:>!]*$/{
                s/.*://
                p
            }'
 *** Src/mkstamp.sh	1997/01/29 03:25:19	1.6
 --- Src/mkstamp.sh	1997/03/23 21:05:26
 ***************
 *** 18,24 ****
   trap "rm -f $STMP.tmp; exit 1" 1 2 15
   echo > $STMP.tmp
   for mod in `cat $MODBINS`; do
 !     sed='/^ *'$mod' *:[^:>]*$/{
                s/.*://
                p
            }'
 --- 18,24 ----
   trap "rm -f $STMP.tmp; exit 1" 1 2 15
   echo > $STMP.tmp
   for mod in `cat $MODBINS`; do
 !     sed='/^ *'$mod' *:[^:>!]*$/{
                s/.*://
                p
            }'
 *** Src/xmods.conf	1997/03/18 23:56:46	1.7
 --- Src/xmods.conf	1997/03/23 21:01:39
 ***************
 *** 10,16 ****
   # is unavailable, and makes the specified builtins be autoloaded if the module
   # is not linked in and dynamic linking is available.  Any more complicated
   # code must be handled as a special case in init_bltinmods(), using the
 ! # {UN,}LINKED_XMOD_* macros.
   #
   # The second type of entry, defining a dependency, looks like this:
   #     module_name : module ...
 --- 10,18 ----
   # is unavailable, and makes the specified builtins be autoloaded if the module
   # is not linked in and dynamic linking is available.  Any more complicated
   # code must be handled as a special case in init_bltinmods(), using the
 ! # {UN,}LINKED_XMOD_* macros.  If the `>' is replaced by `!', this indicates
 ! # that symbols from the module are used in other modules, so the module will
 ! # be linked in by default if RTLD_GLOBAL doesn't work.
   #
   # The second type of entry, defining a dependency, looks like this:
   #     module_name : module ...
 ***************
 *** 24,30 ****
   # (This would be rather neater if we could rely on shell functions in sh.)
   #
   
 ! comp1>
   
   zle> bindkey vared zle
   zle: comp1
 --- 26,32 ----
   # (This would be rather neater if we could rely on shell functions in sh.)
   #
   
 ! comp1!
   
   zle> bindkey vared zle
   zle: comp1

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: ascii

iQCVAwUBMzWesXD/+HJTpU/hAQGODgQAnMUojEk2CQOy9VEO3MZc/Mz5elBVVPTD
Gztl1YKi7PMeNejKYPJbdy5LOzotA24QhurhBcF4qGClFWqX6OaavL+GJ6gDs0qO
V/Gq0H++vrfWZNPNp+dmAD+/Y0qb3qEB7m98c6047TPMkas28No9PNbt0HmbgBTV
MBpfuQ+evBs=
=gsU1
-----END PGP SIGNATURE-----



Messages sorted by: Reverse Date, Date, Thread, Author