* 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>
* libtool.m4 (AC_LIBTOOL_SYS_DYNAMIC_LINKER): Add support for
@ -134,7 +140,7 @@
* f77demo/configure.ac: Add config.h which was misapplied previously.
2003-03-20 Peter O'Gorman <peter@pogma.com>
* ltmain.in: Always use $echo not echo for consistency.
Changes for darwin building. Warn if linking against libs linked
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,
and reset them for a C++ environment. Use the with_gnu_ld setting
from AC_PROG_LD.
* libtool.m4: Replace $linker_flags with $compiler_flags wherever
it is used as argument to $CC.
@ -307,8 +313,8 @@
* ltmain.in: add code for a binary wrapper
to use with uninstalled executables on cygwin/mingw.
Make sure that --mode=clean gets shell wrapper and
binary wrapper. When sourcing the shell wrapper,
invoke using a terminal `.' on cygwin/mingw to
binary wrapper. When sourcing the shell wrapper,
invoke using a terminal `.' on cygwin/mingw to
avoid the automatic append-.exe behavior.
2003-01-28 Albert Chin-A-Young <china@thewrittenword.com>
@ -378,7 +384,7 @@
Call that instead.
2002-12-30 Robert Boehne <rboehne@gnu.org>
* libtool.m4 (AC_LIBTOOL_LANG_CXX_CONFIG): Copy the section
for Darwin from AC_LIBTOOL_PROG_LD_SHLIBS so that the CXX
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;
#ifndef NSADDIMAGE_OPTION_NONE
#define NSADDIMAGE_OPTION_NONE 0x0
#define NSADDIMAGE_OPTION_NONE 0x0
#endif
#ifndef NSADDIMAGE_OPTION_RETURN_ON_ERROR
#define NSADDIMAGE_OPTION_RETURN_ON_ERROR 0x1
#endif
#endif
#ifndef NSADDIMAGE_OPTION_WITH_SEARCHING
#define NSADDIMAGE_OPTION_WITH_SEARCHING 0x2
#endif
#endif
#ifndef NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED
#define NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED 0x4
#endif
@ -1622,7 +1622,7 @@ static enum DYLD_BOOL (*ltdl_NSMakePrivateModulePublic)(NSModule module) = 0;
#endif
#ifndef NSLOOKUPSYMBOLINIMAGE_OPTION_BIND
#define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND 0x0
#endif
#endif
#ifndef NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW
#define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW 0x1
#endif
@ -1643,11 +1643,11 @@ lt_int_dyld_error(othererror)
int lerno;
const char *errstr;
const char *file;
NSLinkEditError(&ler,&lerno,&file,&errstr);
NSLinkEditError(&ler,&lerno,&file,&errstr);
if (!errstr || !strlen(errstr)) errstr = othererror;
return errstr;
}
static const struct mach_header *
lt_int_dyld_get_mach_header_from_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)
const struct mach_header *mh;
{
{
/* 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
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;
struct load_command *lc;
unsigned long offset = sizeof(struct mach_header);
const struct mach_header *mh1;
const char* retStr=NULL;
for (j = 0; j < mh->ncmds; j++)
{
lc = (struct load_command*)(((unsigned long)mh) + offset);
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);
}
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 j;
const struct mach_header *mh=NULL;
const char *id=NULL;
const char *id=NULL;
for (j = 0; j < i; 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;
}
static NSSymbol
lt_int_dyld_NSlookupSymbolInLinkedLibs(symbol,mh)
const char *symbol;
@ -1732,26 +1731,26 @@ lt_int_dyld_NSlookupSymbolInLinkedLibs(symbol,mh)
lc = (struct load_command*)(((unsigned long)mh) + offset);
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));
if (!mh1)
{
/* Maybe NSAddImage can find it */
mh1=ltdl_NSAddImage((char*)(((struct dylib_command*)lc)->dylib.name.offset +
{
/* Maybe NSAddImage can find it */
mh1=ltdl_NSAddImage((char*)(((struct dylib_command*)lc)->dylib.name.offset +
(unsigned long)lc),
NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED +
NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED +
NSADDIMAGE_OPTION_WITH_SEARCHING +
NSADDIMAGE_OPTION_RETURN_ON_ERROR );
}
}
if (mh1)
{
retSym = ltdl_NSLookupSymbolInImage(mh1,
symbol,
NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW
NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW
| NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR
);
if (retSym) break;
}
if (retSym) break;
}
}
offset += lc->cmdsize;
}
@ -1764,7 +1763,7 @@ sys_dyld_init()
{
int retCode = 0;
int err = 0;
if (!_dyld_present()) {
if (!_dyld_present()) {
retCode=1;
}
else {
@ -1784,8 +1783,8 @@ sys_dyld_open (loader_data, filename)
lt_module module = 0;
NSObjectFileImage ofi = 0;
NSObjectFileImageReturnCode ofirc;
if (!filename)
if (!filename)
return (lt_module)-1;
ofirc = NSCreateObjectFileImageFromFile(filename, &ofi);
switch (ofirc)
@ -1802,9 +1801,9 @@ sys_dyld_open (loader_data, filename)
case NSObjectFileImageInappropriateFile:
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;
}
}
default:
LT_DLMUTEX_SETERROR (lt_int_dyld_error(LT_DLSTRERROR(CANNOT_OPEN)));
return 0;
@ -1820,13 +1819,12 @@ sys_dyld_close (loader_data, module)
{
int retCode = 0;
int flags = 0;
unsigned long size=0;
if (module == (lt_module)-1) return 0;
#ifdef __BIG_ENDIAN__
#ifdef __BIG_ENDIAN__
if (((struct mach_header *)module)->magic == MH_MAGIC)
#else
#else
if (((struct mach_header *)module)->magic == MH_CIGAM)
#endif
#endif
{
LT_DLMUTEX_SETERROR("Can not close a dylib");
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
get a segfault in atexit(), due to compiler and dynamic loader differences of
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),
"__DATA","__mod_term_func"))
{
flags += NSUNLINKMODULE_OPTION_KEEP_MEMORY_MAPPED;
}
#endif
}
#endif
#ifdef __ppc__
flags += NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES;
#endif
@ -1852,9 +1850,9 @@ sys_dyld_close (loader_data, module)
{
retCode=1;
LT_DLMUTEX_SETERROR (lt_int_dyld_error(LT_DLSTRERROR(CANNOT_CLOSE)));
}
}
}
return retCode;
}
@ -1873,39 +1871,39 @@ sys_dyld_sym (loader_data, module, symbol)
_dyld_lookup_and_bind(symbol,(unsigned long*)&address,&unused);
return address;
}
#ifdef __BIG_ENDIAN__
#ifdef __BIG_ENDIAN__
if (((struct mach_header *)module)->magic == MH_MAGIC)
#else
#else
if (((struct mach_header *)module)->magic == MH_CIGAM)
#endif
#endif
{
if (ltdl_NSIsSymbolNameDefinedInImage && ltdl_NSLookupSymbolInImage)
{
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,
symbol,
NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW
NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW
| NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR
);
}
}
}
}
}
else {
nssym = NSLookupSymbolInModule(module, symbol);
}
if (!nssym)
if (!nssym)
{
if (!mh) mh=lt_int_dyld_get_mach_header_from_nsmodule(module);
nssym = lt_int_dyld_NSlookupSymbolInLinkedLibs(symbol,mh);
}
if (!nssym)
}
if (!nssym)
{
LT_DLMUTEX_SETERROR (lt_int_dyld_error(LT_DLSTRERROR(SYMBOL_NOT_FOUND)));
return NULL;
}
}
return NSAddressOfSymbol(nssym);
}