* libltdl/ltdl.c (lt_int_dyld_lib_install_name): Removed unused

variable mh1.
(sys_dyld_close): Removed unused variable size.
This commit is contained in:
Gary V. Vaughan 2003-05-30 15:21:46 +00:00
parent cf3a644d94
commit b6dc76b844
2 changed files with 56 additions and 52 deletions

View File

@ -1,3 +1,9 @@
2003-05-29 Gary V. Vaughan <gary@gnu.org>
* libltdl/ltdl.c (lt_int_dyld_lib_install_name): Removed unused
variable mh1.
(sys_dyld_close): Removed unused variable size.
2003-05-21 Bruno Haible <bruno@clisp.org> 2003-05-21 Bruno Haible <bruno@clisp.org>
* libtool.m4 (AC_LIBTOOL_SYS_DYNAMIC_LINKER): Add support for * libtool.m4 (AC_LIBTOOL_SYS_DYNAMIC_LINKER): Add support for
@ -134,7 +140,7 @@
* f77demo/configure.ac: Add config.h which was misapplied previously. * f77demo/configure.ac: Add config.h which was misapplied previously.
2003-03-20 Peter O'Gorman <peter@pogma.com> 2003-03-20 Peter O'Gorman <peter@pogma.com>
* ltmain.in: Always use $echo not echo for consistency. * ltmain.in: Always use $echo not echo for consistency.
Changes for darwin building. Warn if linking against libs linked Changes for darwin building. Warn if linking against libs linked
with -module. Use module_cmds if available and building a module, with -module. Use module_cmds if available and building a module,
@ -229,7 +235,7 @@
(_LT_AC_LANG_CXX_CONFIG): Preserve variables used by AC_PROG_LD, (_LT_AC_LANG_CXX_CONFIG): Preserve variables used by AC_PROG_LD,
and reset them for a C++ environment. Use the with_gnu_ld setting and reset them for a C++ environment. Use the with_gnu_ld setting
from AC_PROG_LD. from AC_PROG_LD.
* libtool.m4: Replace $linker_flags with $compiler_flags wherever * libtool.m4: Replace $linker_flags with $compiler_flags wherever
it is used as argument to $CC. it is used as argument to $CC.
@ -307,8 +313,8 @@
* ltmain.in: add code for a binary wrapper * ltmain.in: add code for a binary wrapper
to use with uninstalled executables on cygwin/mingw. to use with uninstalled executables on cygwin/mingw.
Make sure that --mode=clean gets shell wrapper and Make sure that --mode=clean gets shell wrapper and
binary wrapper. When sourcing the shell wrapper, binary wrapper. When sourcing the shell wrapper,
invoke using a terminal `.' on cygwin/mingw to invoke using a terminal `.' on cygwin/mingw to
avoid the automatic append-.exe behavior. avoid the automatic append-.exe behavior.
2003-01-28 Albert Chin-A-Young <china@thewrittenword.com> 2003-01-28 Albert Chin-A-Young <china@thewrittenword.com>
@ -378,7 +384,7 @@
Call that instead. Call that instead.
2002-12-30 Robert Boehne <rboehne@gnu.org> 2002-12-30 Robert Boehne <rboehne@gnu.org>
* libtool.m4 (AC_LIBTOOL_LANG_CXX_CONFIG): Copy the section * libtool.m4 (AC_LIBTOOL_LANG_CXX_CONFIG): Copy the section
for Darwin from AC_LIBTOOL_PROG_LD_SHLIBS so that the CXX for Darwin from AC_LIBTOOL_PROG_LD_SHLIBS so that the CXX
tag doesn't use the g++ defaults for the OS X compiler. tag doesn't use the g++ defaults for the OS X compiler.

View File

@ -1606,14 +1606,14 @@ static enum DYLD_BOOL (*ltdl_NSIsSymbolNameDefinedInImage)(const struct mach_hea
static enum DYLD_BOOL (*ltdl_NSMakePrivateModulePublic)(NSModule module) = 0; static enum DYLD_BOOL (*ltdl_NSMakePrivateModulePublic)(NSModule module) = 0;
#ifndef NSADDIMAGE_OPTION_NONE #ifndef NSADDIMAGE_OPTION_NONE
#define NSADDIMAGE_OPTION_NONE 0x0 #define NSADDIMAGE_OPTION_NONE 0x0
#endif #endif
#ifndef NSADDIMAGE_OPTION_RETURN_ON_ERROR #ifndef NSADDIMAGE_OPTION_RETURN_ON_ERROR
#define NSADDIMAGE_OPTION_RETURN_ON_ERROR 0x1 #define NSADDIMAGE_OPTION_RETURN_ON_ERROR 0x1
#endif #endif
#ifndef NSADDIMAGE_OPTION_WITH_SEARCHING #ifndef NSADDIMAGE_OPTION_WITH_SEARCHING
#define NSADDIMAGE_OPTION_WITH_SEARCHING 0x2 #define NSADDIMAGE_OPTION_WITH_SEARCHING 0x2
#endif #endif
#ifndef NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED #ifndef NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED
#define NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED 0x4 #define NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED 0x4
#endif #endif
@ -1622,7 +1622,7 @@ static enum DYLD_BOOL (*ltdl_NSMakePrivateModulePublic)(NSModule module) = 0;
#endif #endif
#ifndef NSLOOKUPSYMBOLINIMAGE_OPTION_BIND #ifndef NSLOOKUPSYMBOLINIMAGE_OPTION_BIND
#define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND 0x0 #define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND 0x0
#endif #endif
#ifndef NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW #ifndef NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW
#define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW 0x1 #define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW 0x1
#endif #endif
@ -1643,11 +1643,11 @@ lt_int_dyld_error(othererror)
int lerno; int lerno;
const char *errstr; const char *errstr;
const char *file; const char *file;
NSLinkEditError(&ler,&lerno,&file,&errstr); NSLinkEditError(&ler,&lerno,&file,&errstr);
if (!errstr || !strlen(errstr)) errstr = othererror; if (!errstr || !strlen(errstr)) errstr = othererror;
return errstr; return errstr;
} }
static const struct mach_header * static const struct mach_header *
lt_int_dyld_get_mach_header_from_nsmodule(module) lt_int_dyld_get_mach_header_from_nsmodule(module)
NSModule module; NSModule module;
@ -1671,7 +1671,7 @@ lt_int_dyld_get_mach_header_from_nsmodule(module)
static const char* lt_int_dyld_lib_install_name(mh) static const char* lt_int_dyld_lib_install_name(mh)
const struct mach_header *mh; const struct mach_header *mh;
{ {
/* NSAddImage is also used to get the loaded image, but it only works if the lib /* NSAddImage is also used to get the loaded image, but it only works if the lib
is installed, for uninstalled libs we need to check the install_names against is installed, for uninstalled libs we need to check the install_names against
each other. Note that this is still broken if DYLD_IMAGE_SUFFIX is set and a each other. Note that this is still broken if DYLD_IMAGE_SUFFIX is set and a
@ -1680,14 +1680,13 @@ static const char* lt_int_dyld_lib_install_name(mh)
int j; int j;
struct load_command *lc; struct load_command *lc;
unsigned long offset = sizeof(struct mach_header); unsigned long offset = sizeof(struct mach_header);
const struct mach_header *mh1;
const char* retStr=NULL; const char* retStr=NULL;
for (j = 0; j < mh->ncmds; j++) for (j = 0; j < mh->ncmds; j++)
{ {
lc = (struct load_command*)(((unsigned long)mh) + offset); lc = (struct load_command*)(((unsigned long)mh) + offset);
if (LC_ID_DYLIB == lc->cmd) if (LC_ID_DYLIB == lc->cmd)
{ {
retStr=(char*)(((struct dylib_command*)lc)->dylib.name.offset + retStr=(char*)(((struct dylib_command*)lc)->dylib.name.offset +
(unsigned long)lc); (unsigned long)lc);
} }
offset += lc->cmdsize; offset += lc->cmdsize;
@ -1701,7 +1700,7 @@ lt_int_dyld_match_loaded_lib_by_install_name(const char *name)
int i=_dyld_image_count(); int i=_dyld_image_count();
int j; int j;
const struct mach_header *mh=NULL; const struct mach_header *mh=NULL;
const char *id=NULL; const char *id=NULL;
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
{ {
id=lt_int_dyld_lib_install_name(_dyld_get_image_header(j)); id=lt_int_dyld_lib_install_name(_dyld_get_image_header(j));
@ -1713,7 +1712,7 @@ lt_int_dyld_match_loaded_lib_by_install_name(const char *name)
} }
return mh; return mh;
} }
static NSSymbol static NSSymbol
lt_int_dyld_NSlookupSymbolInLinkedLibs(symbol,mh) lt_int_dyld_NSlookupSymbolInLinkedLibs(symbol,mh)
const char *symbol; const char *symbol;
@ -1732,26 +1731,26 @@ lt_int_dyld_NSlookupSymbolInLinkedLibs(symbol,mh)
lc = (struct load_command*)(((unsigned long)mh) + offset); lc = (struct load_command*)(((unsigned long)mh) + offset);
if ((LC_LOAD_DYLIB == lc->cmd) || (LC_LOAD_WEAK_DYLIB == lc->cmd)) if ((LC_LOAD_DYLIB == lc->cmd) || (LC_LOAD_WEAK_DYLIB == lc->cmd))
{ {
mh1=lt_int_dyld_match_loaded_lib_by_install_name((char*)(((struct dylib_command*)lc)->dylib.name.offset + mh1=lt_int_dyld_match_loaded_lib_by_install_name((char*)(((struct dylib_command*)lc)->dylib.name.offset +
(unsigned long)lc)); (unsigned long)lc));
if (!mh1) if (!mh1)
{ {
/* Maybe NSAddImage can find it */ /* Maybe NSAddImage can find it */
mh1=ltdl_NSAddImage((char*)(((struct dylib_command*)lc)->dylib.name.offset + mh1=ltdl_NSAddImage((char*)(((struct dylib_command*)lc)->dylib.name.offset +
(unsigned long)lc), (unsigned long)lc),
NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED + NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED +
NSADDIMAGE_OPTION_WITH_SEARCHING + NSADDIMAGE_OPTION_WITH_SEARCHING +
NSADDIMAGE_OPTION_RETURN_ON_ERROR ); NSADDIMAGE_OPTION_RETURN_ON_ERROR );
} }
if (mh1) if (mh1)
{ {
retSym = ltdl_NSLookupSymbolInImage(mh1, retSym = ltdl_NSLookupSymbolInImage(mh1,
symbol, symbol,
NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW
| NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR
); );
if (retSym) break; if (retSym) break;
} }
} }
offset += lc->cmdsize; offset += lc->cmdsize;
} }
@ -1764,7 +1763,7 @@ sys_dyld_init()
{ {
int retCode = 0; int retCode = 0;
int err = 0; int err = 0;
if (!_dyld_present()) { if (!_dyld_present()) {
retCode=1; retCode=1;
} }
else { else {
@ -1784,8 +1783,8 @@ sys_dyld_open (loader_data, filename)
lt_module module = 0; lt_module module = 0;
NSObjectFileImage ofi = 0; NSObjectFileImage ofi = 0;
NSObjectFileImageReturnCode ofirc; NSObjectFileImageReturnCode ofirc;
if (!filename) if (!filename)
return (lt_module)-1; return (lt_module)-1;
ofirc = NSCreateObjectFileImageFromFile(filename, &ofi); ofirc = NSCreateObjectFileImageFromFile(filename, &ofi);
switch (ofirc) switch (ofirc)
@ -1802,9 +1801,9 @@ sys_dyld_open (loader_data, filename)
case NSObjectFileImageInappropriateFile: case NSObjectFileImageInappropriateFile:
if (ltdl_NSIsSymbolNameDefinedInImage && ltdl_NSLookupSymbolInImage) if (ltdl_NSIsSymbolNameDefinedInImage && ltdl_NSLookupSymbolInImage)
{ {
module = (lt_module)ltdl_NSAddImage(filename, NSADDIMAGE_OPTION_RETURN_ON_ERROR); module = (lt_module)ltdl_NSAddImage(filename, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
break; break;
} }
default: default:
LT_DLMUTEX_SETERROR (lt_int_dyld_error(LT_DLSTRERROR(CANNOT_OPEN))); LT_DLMUTEX_SETERROR (lt_int_dyld_error(LT_DLSTRERROR(CANNOT_OPEN)));
return 0; return 0;
@ -1820,13 +1819,12 @@ sys_dyld_close (loader_data, module)
{ {
int retCode = 0; int retCode = 0;
int flags = 0; int flags = 0;
unsigned long size=0;
if (module == (lt_module)-1) return 0; if (module == (lt_module)-1) return 0;
#ifdef __BIG_ENDIAN__ #ifdef __BIG_ENDIAN__
if (((struct mach_header *)module)->magic == MH_MAGIC) if (((struct mach_header *)module)->magic == MH_MAGIC)
#else #else
if (((struct mach_header *)module)->magic == MH_CIGAM) if (((struct mach_header *)module)->magic == MH_CIGAM)
#endif #endif
{ {
LT_DLMUTEX_SETERROR("Can not close a dylib"); LT_DLMUTEX_SETERROR("Can not close a dylib");
retCode = 1; retCode = 1;
@ -1837,14 +1835,14 @@ sys_dyld_close (loader_data, module)
/* Currently, if a module contains c++ static destructors and it is unloaded, we /* Currently, if a module contains c++ static destructors and it is unloaded, we
get a segfault in atexit(), due to compiler and dynamic loader differences of get a segfault in atexit(), due to compiler and dynamic loader differences of
opinion, this works around that. opinion, this works around that.
*/ */
if ((const struct section *)NULL != if ((const struct section *)NULL !=
getsectbynamefromheader(lt_int_dyld_get_mach_header_from_nsmodule(module), getsectbynamefromheader(lt_int_dyld_get_mach_header_from_nsmodule(module),
"__DATA","__mod_term_func")) "__DATA","__mod_term_func"))
{ {
flags += NSUNLINKMODULE_OPTION_KEEP_MEMORY_MAPPED; flags += NSUNLINKMODULE_OPTION_KEEP_MEMORY_MAPPED;
} }
#endif #endif
#ifdef __ppc__ #ifdef __ppc__
flags += NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES; flags += NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES;
#endif #endif
@ -1852,9 +1850,9 @@ sys_dyld_close (loader_data, module)
{ {
retCode=1; retCode=1;
LT_DLMUTEX_SETERROR (lt_int_dyld_error(LT_DLSTRERROR(CANNOT_CLOSE))); LT_DLMUTEX_SETERROR (lt_int_dyld_error(LT_DLSTRERROR(CANNOT_CLOSE)));
} }
} }
return retCode; return retCode;
} }
@ -1873,39 +1871,39 @@ sys_dyld_sym (loader_data, module, symbol)
_dyld_lookup_and_bind(symbol,(unsigned long*)&address,&unused); _dyld_lookup_and_bind(symbol,(unsigned long*)&address,&unused);
return address; return address;
} }
#ifdef __BIG_ENDIAN__ #ifdef __BIG_ENDIAN__
if (((struct mach_header *)module)->magic == MH_MAGIC) if (((struct mach_header *)module)->magic == MH_MAGIC)
#else #else
if (((struct mach_header *)module)->magic == MH_CIGAM) if (((struct mach_header *)module)->magic == MH_CIGAM)
#endif #endif
{ {
if (ltdl_NSIsSymbolNameDefinedInImage && ltdl_NSLookupSymbolInImage) if (ltdl_NSIsSymbolNameDefinedInImage && ltdl_NSLookupSymbolInImage)
{ {
mh=module; mh=module;
if (ltdl_NSIsSymbolNameDefinedInImage((struct mach_header*)module,symbol)) if (ltdl_NSIsSymbolNameDefinedInImage((struct mach_header*)module,symbol))
{ {
nssym = ltdl_NSLookupSymbolInImage((struct mach_header*)module, nssym = ltdl_NSLookupSymbolInImage((struct mach_header*)module,
symbol, symbol,
NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW
| NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR
); );
} }
} }
} }
else { else {
nssym = NSLookupSymbolInModule(module, symbol); nssym = NSLookupSymbolInModule(module, symbol);
} }
if (!nssym) if (!nssym)
{ {
if (!mh) mh=lt_int_dyld_get_mach_header_from_nsmodule(module); if (!mh) mh=lt_int_dyld_get_mach_header_from_nsmodule(module);
nssym = lt_int_dyld_NSlookupSymbolInLinkedLibs(symbol,mh); nssym = lt_int_dyld_NSlookupSymbolInLinkedLibs(symbol,mh);
} }
if (!nssym) if (!nssym)
{ {
LT_DLMUTEX_SETERROR (lt_int_dyld_error(LT_DLSTRERROR(SYMBOL_NOT_FOUND))); LT_DLMUTEX_SETERROR (lt_int_dyld_error(LT_DLSTRERROR(SYMBOL_NOT_FOUND)));
return NULL; return NULL;
} }
return NSAddressOfSymbol(nssym); return NSAddressOfSymbol(nssym);
} }