From 310990651488c6255e6ac558d56b3ab79cde316e Mon Sep 17 00:00:00 2001 From: steve Date: Mon, 17 Sep 2001 22:26:33 +0000 Subject: [PATCH] Detect C name mangling for dlsym. --- vvp/config.h.in | 31 +++++++++++++++++++++---- vvp/configure.in | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 4 deletions(-) diff --git a/vvp/config.h.in b/vvp/config.h.in index e8af9db44..94ed5ef26 100644 --- a/vvp/config.h.in +++ b/vvp/config.h.in @@ -19,12 +19,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: config.h.in,v 1.7 2001/09/15 18:27:05 steve Exp $" +#ident "$Id: config.h.in,v 1.8 2001/09/17 22:26:33 steve Exp $" #endif # define SIZEOF_UNSIGNED_LONG 0 # define SIZEOF_UNSIGNED 0 +# undef NEED_LU +# undef NEED_TU +# undef WLU +# undef WTU # undef HAVE_DLFCN_H # undef HAVE_DL_H # undef HAVE_GETOPT_H @@ -33,9 +37,6 @@ # undef ENABLE_VVP_DEBUG -# define LU "" -# define TU "" - #ifndef MODULE_DIR # define MODULE_DIR "." #endif @@ -46,8 +47,30 @@ # undef HAVE_TIMES + +/* + * When doing dynamic linking, we need a uniform way to identify the + * symbol. Some compilers put leading _, some trailing _. The + * configure script figures out which is the local convention and + * defines NEED_LU and NEED_TU as required. + */ +#ifdef NEED_LU +#define LU "_" +#else +#define LU "" +#endif + +#ifdef NEED_TU +#define TU "_" +#else +#define TU "" +#endif + /* * $Log: config.h.in,v $ + * Revision 1.8 2001/09/17 22:26:33 steve + * Detect C name mangling for dlsym. + * * Revision 1.7 2001/09/15 18:27:05 steve * Make configure detect malloc.h * diff --git a/vvp/configure.in b/vvp/configure.in index 1be691582..8bb84d640 100644 --- a/vvp/configure.in +++ b/vvp/configure.in @@ -93,4 +93,63 @@ esac AC_SUBST(EXTRALIBS) AC_MSG_RESULT($EXTRALIBS) +####################### +## test for underscores. The vpi module loader in vvm needs to know this +## in order to know the name of the start symbol for the .vpi module. +####################### + +AC_CYGWIN +AC_EXEEXT +AC_MINGW32 + + +WIN32=no +AC_MSG_CHECKING("Checking for windows") +if test "$CYGWIN" = "yes" -o "$MINGW32" = "yes" +then + WIN32=yes +fi +AC_SUBST(WIN32) +AC_MSG_RESULT($WIN32) +AC_SUBST(EXEEXT) + + +AC_MSG_CHECKING("for leading and/or trailing underscores") +cat << EOF > underscore.c + void underscore(void){} +EOF +$CC -shared -c underscore.c > /dev/null 2>&1 + +CC_LEADING_UNDERSCORE=no +CC_TRAILING_UNDERSCORE=no + +output=`nm underscore.o|grep _underscore 2>&1` +if test ! -z "$output" -a -z "$CYGWIN" -a -z "$MINGW32"; then + CC_LEADING_UNDERSCORE=yes + AC_DEFINE(NEED_LU) +fi + + + +output=`nm underscore.o|grep underscore_ 2>&1` +if test ! -z "$output"; then + CC_TRAILING_UNDERSCORE=yes + AC_DEFINE(NEED_TU) +fi + +if test "$CC_LEADING_UNDERSCORE" = yes; then + AC_DEFINE(WLU) +fi +if test "$CC_TRAILING_UNDERSCORE" = yes; then + AC_DEFINE(WTU) +fi + +rm underscore.c underscore.o + +AC_MSG_RESULT("$CC_LEADING_UNDERSCORE $CC_TRAILING_UNDERSCORE") + +####################### +## end of test for underscores +####################### + AC_OUTPUT(Makefile)