diff --git a/ChangeLog b/ChangeLog index 6a03f42f..b19dc2c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2002-10-30 Charles Wilson + + * libtool.m4 (AC_LIBTOOL_PROG_CC_C_O): use printf, not + echo. (AC_DEPLIBS_CHECK_METHOD): use new shell function + win32_libid on w32 platforms + * ltmain.in: add new section for shell functions. Add + win32_libid() shell function. + * f77demo/Makefile.am: add -no-undefined flag + +2002-10-30 Rob Browning + + * ltdl.c (realloc): Remove custom realloc. (#define + rpl_realloc realloc) and comment out later code for custom + realloc. You can't define your own malloc unless you know + enough about the malloc in use to be able to tell how big + the src ptr is. The disabled code incorrectly used the + *destination* ptr to decide how much to copy. This + sometimes results in out-of-bound accesses which cause + segfaults. This is a quick hack for now; we may want + something cleaner later. (tryall_dlopen_module): check to + be sure (dirname_len > 0) before testing first character + against '/'. (try_dlopen): check for feof(file) in read + loop -- otherwise infloop? + 2002-10-25 Robert Boehne * ltmain.in (-XCClinker): New flag passes a linking option diff --git a/f77demo/Makefile.am b/f77demo/Makefile.am index 9f391e23..702a3526 100644 --- a/f77demo/Makefile.am +++ b/f77demo/Makefile.am @@ -9,7 +9,10 @@ EXTRA_DIST = acinclude.m4 noinst_LTLIBRARIES = libfoo.la libmix.la libfoo_la_SOURCES = foof.f +libfoo_la_LDFLAGS = -no-undefined + libmix_la_SOURCES = foof.f fooc.c +libmix_la_LDFLAGS = -no-undefined noinst_HEADERS = foo.h diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c index dd3ec203..ad6851e2 100644 --- a/libltdl/ltdl.c +++ b/libltdl/ltdl.c @@ -211,7 +211,8 @@ static char *lt_estrdup LT_PARAMS((const char *str)); static lt_ptr lt_emalloc LT_PARAMS((size_t size)); static lt_ptr lt_erealloc LT_PARAMS((lt_ptr addr, size_t size)); -static lt_ptr rpl_realloc LT_PARAMS((lt_ptr ptr, size_t size)); +/* static lt_ptr rpl_realloc LT_PARAMS((lt_ptr ptr, size_t size)); */ +#define rpl_realloc realloc /* These are the pointers that can be changed by the caller: */ LT_GLOBAL_DATA lt_ptr (*lt_dlmalloc) LT_PARAMS((size_t size)) @@ -502,8 +503,15 @@ static struct dirent *readdir(entry) Instead implement our own version (with known boundary conditions) using lt_dlmalloc and lt_dlfree. */ -#undef realloc -#define realloc rpl_realloc +/* #undef realloc + #define realloc rpl_realloc +*/ +#if 0 + /* You can't (re)define realloc unless you also (re)define malloc. + Right now, this code uses the size of the *destination* to decide + how much to copy. That's not right, but you can't know the size + of the source unless you know enough about, or wrote malloc. So + this code is disabled... */ static lt_ptr realloc (ptr, size) @@ -541,6 +549,7 @@ realloc (ptr, size) return mem; } } +#endif #if ! HAVE_ARGZ_APPEND @@ -2107,8 +2116,9 @@ tryall_dlopen_module (handle, prefix, dirname, dlname) assert (strchr (dirname, LT_DIRSEP_CHAR) == 0); #endif - if (dirname[dirname_len -1] == '/') - --dirname_len; + if (dirname_len > 0) + if (dirname[dirname_len -1] == '/') + --dirname_len; filename_len = dirname_len + 1 + LT_STRLEN (dlname); /* Allocate memory, and combine DIRNAME and MODULENAME into it. @@ -2852,7 +2862,7 @@ try_dlopen (phandle, filename) /* Handle the case where we occasionally need to read a line that is longer than the initial buffer size. */ - while (line[LT_STRLEN(line) -1] != '\n') + while ((line[LT_STRLEN(line) -1] != '\n') && (!feof (file))) { line = LT_DLREALLOC (char, line, line_len *2); if (!fgets (&line[line_len -1], (int) line_len +1, file)) diff --git a/libtool.m4 b/libtool.m4 index 1ee50086..5c2d52b6 100644 --- a/libtool.m4 +++ b/libtool.m4 @@ -874,7 +874,7 @@ AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], FFLAGS="$FFLAGS -o out/conftest2.$ac_objext"], [$1],[GCJ],[save_GCJFLAGS="$CFLAGS" CFLAGS="$GCJFLAGS -o out/conftest2.$ac_objext"]) - echo "$lt_simple_compile_test_code" > conftest.$ac_ext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext # According to Tom Tromey, Ian Lance Taylor reported there are C compilers # that will create temporary files in the current directory regardless of @@ -1947,8 +1947,9 @@ bsdi4*) ;; cygwin* | mingw* | pw32*) - lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' - lt_cv_file_magic_cmd='$OBJDUMP -f' + # win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='win32_libid' ;; darwin* | rhapsody*) diff --git a/ltmain.in b/ltmain.in index 13001420..f293d4ee 100644 --- a/ltmain.in +++ b/ltmain.in @@ -114,6 +114,40 @@ execute_dlfiles= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" +##################################### +# Shell function definitions: +# This seems to be the best place for them + +# Need a lot of goo to handle *both* DLLs and import libs +# Has to be a shell function in order to 'eat' the argument +# that is supplied when $file_magic_command is called. +win32_libid () { + win32_libid_type="unknown" + if eval $OBJDUMP -f $1 2>/dev/null | \ + grep -E 'file format pei+-i386(.*architecture: i386)?' >/dev/null ; then + win32_libid_type="x86 DLL" + else + if eval $OBJDUMP -f $1 2>/dev/null | \ + grep -E 'file format pei*-i386(.*architecture: i386)?' >/dev/null ; then + win32_libid_type="x86" + if eval file $1 2>/dev/null | \ + grep -E 'ar archive' >/dev/null; then + win32_libid_type="$win32_libid_type archive" + if eval $NM -f posix -A $1 | awk '{print $3}' | grep "I" >/dev/null ; then + win32_libid_type="$win32_libid_type import" + else + win32_libid_type="$win32_libid_type static" + fi + fi + fi + fi + echo $win32_libid_type +} + +# End of Shell function definitions +##################################### + + # Parse our command line options once, thoroughly. while test "$#" -gt 0 do