From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14612 invoked from network); 25 Mar 1997 23:10:58 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by coral.primenet.com.au with SMTP; 25 Mar 1997 23:10:58 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id RAA03256; Tue, 25 Mar 1997 17:55:45 -0500 (EST) Resent-Date: Tue, 25 Mar 1997 17:55:45 -0500 (EST) Date: Mon, 24 Mar 1997 18:51:59 GMT From: Zefram Message-Id: <28116.199703241851@stone.dcs.warwick.ac.uk> Subject: RTLD_GLOBAL test X-Patch: 229 Resent-Message-ID: <"0ZvKl.0.lo.kV5Ep"@euclid> To: zsh-workers@math.gatech.edu Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/3030 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu -----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 + #else + #include + #include + #include + #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-----