本文整理汇总了C++中NSLinkEditError函数的典型用法代码示例。如果您正苦于以下问题:C++ NSLinkEditError函数的具体用法?C++ NSLinkEditError怎么用?C++ NSLinkEditError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NSLinkEditError函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: dlerror
const char*
dlerror()
{
NSLinkEditErrors c;
int errorNumber;
const char *fileName, *errorString;
char *result = NULL;
if (last_error) {
NSLinkEditError(&c, &errorNumber, &fileName, &errorString);
/* The errorString obtained by the above is too verbose for
* our needs, so we just translate the errno.
*
* We also have simple fallbacks in case we've somehow lost
* the context before this point. */
if (errorNumber) {
result = strerror(errorNumber);
} else if (DLSYM_ERROR == last_error) {
result = "dlsym(3) failed";
} else if (DLOPEN_ERROR == last_error) {
result = "dlopen(3) failed";
}
last_error = 0;
}
return result;
}
开发者ID:nixeagle,项目名称:sbcl,代码行数:27,代码来源:darwin-dlshim.c
示例2: pr_LoadMachDyldModule
static NSModule
pr_LoadMachDyldModule(const char *name)
{
NSObjectFileImage ofi;
NSModule h = NULL;
if (NSCreateObjectFileImageFromFile(name, &ofi)
== NSObjectFileImageSuccess) {
h = NSLinkModule(ofi, name, NSLINKMODULE_OPTION_PRIVATE
| NSLINKMODULE_OPTION_RETURN_ON_ERROR);
if (h == NULL) {
NSLinkEditErrors linkEditError;
int errorNum;
const char *fileName;
const char *errorString;
NSLinkEditError(&linkEditError, &errorNum, &fileName, &errorString);
PR_LOG(_pr_linker_lm, PR_LOG_MIN,
("LoadMachDyldModule error %d:%d for file %s:\n%s",
linkEditError, errorNum, fileName, errorString));
}
if (NSDestroyObjectFileImage(ofi) == FALSE) {
if (h) {
(void)NSUnLinkModule(h, NSUNLINKMODULE_OPTION_NONE);
h = NULL;
}
}
}
return h;
}
开发者ID:sahlberg,项目名称:timberwolf,代码行数:28,代码来源:prlink.c
示例3: OW_LOG_DEBUG
SharedLibraryRef
dyldSharedLibraryLoader::loadSharedLibrary(const String& filename,
const LoggerRef& logger) const
{
OW_LOG_DEBUG(logger, Format("Load request for %1 received.", filename));
NSObjectFileImage image = 0;
NSObjectFileImageReturnCode dsoerr = NSCreateObjectFileImageFromFile(filename.c_str(), &image);
const char* err_msg = NULL;
NSModule libhandle = NULL;
if (dsoerr == NSObjectFileImageSuccess)
{
libhandle = NSLinkModule(image, filename.c_str(), NSLINKMODULE_OPTION_RETURN_ON_ERROR | NSLINKMODULE_OPTION_PRIVATE);
if (!libhandle)
{
NSLinkEditErrors errors;
int errorNumber;
const char *fileName;
NSLinkEditError(&errors, &errorNumber, &fileName, &err_msg);
}
NSDestroyObjectFileImage(image);
}
else if ((dsoerr == NSObjectFileImageFormat ||
dsoerr == NSObjectFileImageInappropriateFile) &&
NSAddLibrary(filename.c_str()) == TRUE)
{
OW_LOG_ERROR(logger, Format("NSCreateObject: %1 failed with error \"%2\"",
filename, dsoerr));
// libhandle = (NSModule)DYLD_LIBRARY_HANDLE;
}
else
{
err_msg = "cannot create object file image or add library";
OW_LOG_ERROR(logger, Format("NSCreateObject: %1 failed with error %2",
filename, dsoerr));
}
if (libhandle)
{
try
{
return SharedLibraryRef( new dyldSharedLibrary(libhandle,
filename));
}
catch (...)
{
NSUnLinkModule(libhandle, FALSE);
throw;
}
}
else
{
OW_LOG_ERROR(logger, Format("dyldSharedLibraryLoader::loadSharedLibrary:"
" %1", err_msg));
return SharedLibraryRef( 0 );
}
}
开发者ID:kkaempf,项目名称:openwbem,代码行数:59,代码来源:OW_dyldSharedLibraryLoader.cpp
示例4: NSLinkEditError
const char *vmddlerror( void ) {
NSLinkEditErrors c;
int errorNumber;
const char *fileName;
const char *errorString = NULL;
NSLinkEditError(&c, &errorNumber, &fileName, &errorString);
return errorString;
}
开发者ID:yupinov,项目名称:gromacs,代码行数:8,代码来源:vmddlopen.c
示例5: pusherror
static void pusherror (lua_State *L) {
const char* err_str;
const char* err_file;
NSLinkEditErrors err;
int err_num;
NSLinkEditError(&err, &err_num, &err_file, &err_str);
lua_pushstring(L, err_str);
}
开发者ID:Isaacssv552,项目名称:ufoai,代码行数:8,代码来源:loadlib.cpp
示例6: logDyldError
static void
logDyldError (const char *action) {
NSLinkEditErrors errors;
int number;
const char *file;
const char *message;
NSLinkEditError(&errors, &number, &file, &message);
logMessage(LOG_ERR, "%.*s", (int)(strlen(message)-1), message);
}
开发者ID:mlang,项目名称:brltty,代码行数:9,代码来源:dynld_dyld.c
示例7: caml_dlerror
char * caml_dlerror(void)
{
NSLinkEditErrors c;
int errnum;
const char *fileName, *errorString;
if (dlerror_string != NULL) return dlerror_string;
NSLinkEditError(&c,&errnum,&fileName,&errorString);
return (char *) errorString;
}
开发者ID:avsm,项目名称:ocaml-community,代码行数:9,代码来源:unix.c
示例8: WXUNUSED
static void *wx_darwin_dlopen(const char *path, int WXUNUSED(mode) /* mode is ignored */)
{
NSObjectFileImage ofile;
NSModule handle = NULL;
unsigned dyld_result = NSCreateObjectFileImageFromFile(path, &ofile);
if ( dyld_result != NSObjectFileImageSuccess )
{
handle = NULL;
static const char *const errorStrings[] =
{
"%d: Object Image Load Failure",
"%d: Object Image Load Success",
"%d: Not an recognisable object file",
"%d: No valid architecture",
"%d: Object image has an invalid format",
"%d: Invalid access (permissions?)",
"%d: Unknown error code from NSCreateObjectFileImageFromFile"
};
const int index = dyld_result < WXSIZEOF(errorStrings)
? dyld_result
: WXSIZEOF(errorStrings) - 1;
// this call to sprintf() is safe as strings above are fixed at
// compile-time and are shorter than WXSIZEOF(dl_last_error)
sprintf(dl_last_error, errorStrings[index], dyld_result);
}
else
{
handle = NSLinkModule
(
ofile,
path,
NSLINKMODULE_OPTION_BINDNOW |
NSLINKMODULE_OPTION_RETURN_ON_ERROR
);
if ( !handle )
{
NSLinkEditErrors err;
int code;
const char *filename;
const char *errmsg;
NSLinkEditError(&err, &code, &filename, &errmsg);
strncpy(dl_last_error, errmsg, WXSIZEOF(dl_last_error)-1);
dl_last_error[WXSIZEOF(dl_last_error)-1] = '\0';
}
}
return handle;
}
开发者ID:beanhome,项目名称:dev,代码行数:55,代码来源:dlunix.cpp
示例9: dyld_dlerror
static const char * dyld_dlerror()
{
NSLinkEditErrors ler;
int lerno;
const char *errstr;
const char *file;
NSLinkEditError(&ler, &lerno, &file, &errstr);
if (!dyld_error_set) errstr=NULL;
dyld_error_set=0;
return errstr;
}
开发者ID:cention-nazri,项目名称:libdbi,代码行数:11,代码来源:dbi_main.c
示例10: _CFBundleDYLDLoadFramework
CF_PRIVATE Boolean _CFBundleDYLDLoadFramework(CFBundleRef bundle, CFErrorRef *error) {
// !!! Framework loading should be better. Can't unload frameworks.
CFErrorRef localError = NULL, *subError = (error ? &localError : NULL);
NSLinkEditErrors c = NSLinkEditUndefinedError;
int errorNumber = 0;
const char *fileName = NULL;
const char *errorString = NULL;
if (!bundle->_isLoaded) {
CFURLRef executableURL = CFBundleCopyExecutableURL(bundle);
char buff[CFMaxPathSize];
if (executableURL && CFURLGetFileSystemRepresentation(executableURL, true, (uint8_t *)buff, CFMaxPathSize)) {
void *image = (void *)NSAddImage(buff, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
#if LOG_BUNDLE_LOAD
printf("dyld load framework %p, add image of %s returns image %p\n", bundle, buff, image);
#endif /* LOG_BUNDLE_LOAD */
if (image) {
bundle->_imageCookie = image;
bundle->_isLoaded = true;
} else {
NSLinkEditError(&c, &errorNumber, &fileName, &errorString);
if (error) {
#if defined(BINARY_SUPPORT_DLFCN)
_CFBundleDlfcnPreflight(bundle, subError);
#endif /* BINARY_SUPPORT_DLFCN */
if (!localError) {
CFStringRef tempString = CFStringCreateWithFileSystemRepresentation(kCFAllocatorSystemDefault, errorString), debugString = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("error code %d, error number %d (%@)"), c, errorNumber, tempString);
localError = _CFBundleCreateErrorDebug(CFGetAllocator(bundle), bundle, CFBundleExecutableLinkError, debugString);
if (tempString) CFRelease(tempString);
if (debugString) CFRelease(debugString);
}
} else {
CFStringRef tempString = CFStringCreateWithFileSystemRepresentation(kCFAllocatorSystemDefault, errorString), executableString = CFStringCreateWithFileSystemRepresentation(kCFAllocatorSystemDefault, fileName);
CFLog(__kCFLogBundle, CFSTR("Error loading %@: error code %d, error number %d (%@)"), executableString, c, errorNumber, tempString);
if (tempString) CFRelease(tempString);
if (executableString) CFRelease(executableString);
}
}
} else {
if (error) {
localError = _CFBundleCreateError(CFGetAllocator(bundle), bundle, CFBundleExecutableNotFoundError);
} else {
CFLog(__kCFLogBundle, CFSTR("Cannot find executable for bundle %@"), bundle);
}
}
if (executableURL) CFRelease(executableURL);
}
if (!bundle->_isLoaded && error) *error = localError;
return bundle->_isLoaded;
}
开发者ID:parkera,项目名称:swift-corelibs-foundation,代码行数:51,代码来源:CFBundle_Binary.c
示例11: NSLinkEditError
/* Up to the caller to free() returned string */
static inline const char *dyld_error_str()
{
NSLinkEditErrors dylder;
int dylderno;
const char *dylderrstr;
const char *dyldfile;
const char* retStr = NULL;
NSLinkEditError(&dylder, &dylderno, &dyldfile, &dylderrstr);
if (dylderrstr && strlen(dylderrstr))
{
retStr = malloc(strlen(dylderrstr) +1);
strcpy((char*)retStr,dylderrstr);
}
return retStr;
}
开发者ID:Miguel-J,项目名称:eneboo-core,代码行数:16,代码来源:dlfcn.c
示例12: dylderror
/* Return the dyld error string, or the passed in error string if none. */
static const char *
dylderror (const char *errmsg)
{
NSLinkEditErrors ler;
int lerno;
const char *file;
const char *errstr;
NSLinkEditError (&ler, &lerno, &file, &errstr);
if (! (errstr && *errstr))
{
errstr = errmsg;
}
return errstr;
}
开发者ID:kam-zhang,项目名称:kamOwnInformation,代码行数:18,代码来源:dyld.c
示例13: XPCOMGlueLoad
nsresult
XPCOMGlueLoad(const char *xpcomFile, GetFrozenFunctionsFunc *func)
{
const mach_header* lib = nsnull;
if (xpcomFile[0] != '.' || xpcomFile[1] != '\0') {
char xpcomDir[PATH_MAX];
if (realpath(xpcomFile, xpcomDir)) {
char *lastSlash = strrchr(xpcomDir, '/');
if (lastSlash) {
*lastSlash = '\0';
XPCOMGlueLoadDependentLibs(xpcomDir, ReadDependentCB);
snprintf(lastSlash, PATH_MAX - strlen(xpcomDir), "/" XUL_DLL);
sXULLibImage = NSAddImage(xpcomDir,
NSADDIMAGE_OPTION_RETURN_ON_ERROR |
NSADDIMAGE_OPTION_WITH_SEARCHING |
NSADDIMAGE_OPTION_MATCH_FILENAME_BY_INSTALLNAME);
}
}
lib = NSAddImage(xpcomFile,
NSADDIMAGE_OPTION_RETURN_ON_ERROR |
NSADDIMAGE_OPTION_WITH_SEARCHING |
NSADDIMAGE_OPTION_MATCH_FILENAME_BY_INSTALLNAME);
if (!lib) {
NSLinkEditErrors linkEditError;
int errorNum;
const char *errorString;
const char *fileName;
NSLinkEditError(&linkEditError, &errorNum, &fileName, &errorString);
fprintf(stderr, "XPCOMGlueLoad error %d:%d for file %s:\n%s\n",
linkEditError, errorNum, fileName, errorString);
}
}
*func = (GetFrozenFunctionsFunc) LookupSymbol(lib, "_NS_GetFrozenFunctions");
return *func ? NS_OK : NS_ERROR_NOT_AVAILABLE;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:43,代码来源:nsGlueLinkingOSX.cpp
示例14: pg_dlerror
char *
pg_dlerror(void)
{
NSLinkEditErrors c;
int errorNumber;
const char *fileName;
const char *errorString = NULL;
switch (cofiff_result)
{
case NSObjectFileImageSuccess:
/* must have failed in NSLinkModule */
NSLinkEditError(&c, &errorNumber, &fileName, &errorString);
if (errorString == NULL || *errorString == '\0')
errorString = "unknown link-edit failure";
break;
case NSObjectFileImageFailure:
errorString = "failed to open object file";
break;
case NSObjectFileImageInappropriateFile:
errorString = "inappropriate object file";
break;
case NSObjectFileImageArch:
errorString = "object file is for wrong architecture";
break;
case NSObjectFileImageFormat:
errorString = "object file has wrong format";
break;
case NSObjectFileImageAccess:
errorString = "insufficient permissions for object file";
break;
default:
errorString = "unknown failure to open object file";
break;
}
return (char *) errorString;
}
开发者ID:CraigBryan,项目名称:PostgresqlFun,代码行数:38,代码来源:darwin.c
示例15: va_start
/* Set and get the error string for use by dlerror */
static const char *error(int setget, const char *str, ...)
{
static char errstr[ERR_STR_LEN];
static int err_filled = 0;
const char *retval;
NSLinkEditErrors ler;
int lerno;
const char *dylderrstr;
const char *file;
va_list arg;
if (setget <= 0)
{
va_start(arg, str);
strncpy(errstr, "dlsimple: ", ERR_STR_LEN);
str_vsnprintf(errstr + 10, ERR_STR_LEN - 10, str, arg);
va_end(arg);
/* We prefer to use the dyld error string if setget is 0 */
if (setget == 0) {
NSLinkEditError(&ler, &lerno, &file, &dylderrstr);
fprintf(stderr,"dyld: %s\n",dylderrstr);
if (dylderrstr && str_len(dylderrstr))
strncpy(errstr,dylderrstr,ERR_STR_LEN);
}
err_filled = 1;
retval = NULL;
}
else
{
if (!err_filled)
retval = NULL;
else
retval = errstr;
err_filled = 0;
}
return retval;
}
开发者ID:darcyg,项目名称:chaosircd,代码行数:37,代码来源:dlfcn_darwin.c
示例16: TclpLoadMemory
//.........这里部分代码省略.........
"local cputype %d subtype %d, "
"fat cputype %d subtype %d",
arch->cputype | arch_abi, arch->cpusubtype,
fa->cputype, fa->cpusubtype);
mh = (void*)((char*)buffer + fa->offset);
ms = fa->size;
} else {
TclLoadDbgMsg("NXFindBestFatArch() failed");
err = NSObjectFileImageInappropriateFile;
}
if (fh->magic != FAT_MAGIC) {
swap_fat_arch(fatarchs, fh_nfat_arch, arch->byteorder);
}
} else {
TclLoadDbgMsg("Fat binary header failure");
err = NSObjectFileImageInappropriateFile;
}
} else {
/*
* Thin binary
*/
TclLoadDbgMsg("Thin binary");
mh = buffer;
ms = codeSize;
}
if (ms && !(ms >= mh_size && mh->magic == mh_magic &&
mh->filetype == MH_BUNDLE)) {
TclLoadDbgMsg("Inappropriate file: magic %x filetype %d",
mh->magic, mh->filetype);
err = NSObjectFileImageInappropriateFile;
}
if (err == NSObjectFileImageSuccess) {
err = NSCreateObjectFileImageFromMemory(buffer, codeSize,
&dyldObjFileImage);
if (err == NSObjectFileImageSuccess) {
TclLoadDbgMsg("NSCreateObjectFileImageFromMemory() "
"successful");
} else {
objFileImageErrMsg = DyldOFIErrorMsg(err);
TclLoadDbgMsg("NSCreateObjectFileImageFromMemory() failed: %s",
objFileImageErrMsg);
}
} else {
objFileImageErrMsg = DyldOFIErrorMsg(err);
}
}
/*
* If it went wrong (or we were asked to just deallocate), get rid of the
* memory block and create an error message.
*/
if (dyldObjFileImage == NULL) {
vm_deallocate(mach_task_self(), (vm_address_t) buffer, size);
if (objFileImageErrMsg != NULL) {
Tcl_AppendResult(interp, "NSCreateObjectFileImageFromMemory() "
"error: ", objFileImageErrMsg, NULL);
}
return TCL_ERROR;
}
/*
* Extract the module we want from the image of the object file.
*/
module = NSLinkModule(dyldObjFileImage, "[Memory Based Bundle]",
NSLINKMODULE_OPTION_BINDNOW | NSLINKMODULE_OPTION_RETURN_ON_ERROR);
NSDestroyObjectFileImage(dyldObjFileImage);
if (module) {
TclLoadDbgMsg("NSLinkModule() successful");
} else {
NSLinkEditErrors editError;
int errorNumber;
const char *errorName, *errMsg;
NSLinkEditError(&editError, &errorNumber, &errorName, &errMsg);
TclLoadDbgMsg("NSLinkModule() failed: %s", errMsg);
Tcl_AppendResult(interp, errMsg, NULL);
return TCL_ERROR;
}
/*
* Stash the module reference within the load handle we create and return.
*/
modulePtr = (Tcl_DyldModuleHandle *) ckalloc(sizeof(Tcl_DyldModuleHandle));
modulePtr->module = module;
modulePtr->nextPtr = NULL;
dyldLoadHandle = (Tcl_DyldLoadHandle *)
ckalloc(sizeof(Tcl_DyldLoadHandle));
#if TCL_DYLD_USE_DLFCN
dyldLoadHandle->dlHandle = NULL;
#endif
dyldLoadHandle->dyldLibHeader = NULL;
dyldLoadHandle->modulePtr = modulePtr;
*loadHandle = (Tcl_LoadHandle) dyldLoadHandle;
*unloadProcPtr = &TclpUnloadFile;
return TCL_OK;
}
开发者ID:mgarc729,项目名称:tcl8.4.20_udp,代码行数:101,代码来源:tclLoadDyld.c
示例17: TclpFindSymbol
MODULE_SCOPE Tcl_PackageInitProc *
TclpFindSymbol(
Tcl_Interp *interp, /* For error reporting. */
Tcl_LoadHandle loadHandle, /* Handle from TclpDlopen. */
CONST char *symbol) /* Symbol name to look up. */
{
Tcl_DyldLoadHandle *dyldLoadHandle = (Tcl_DyldLoadHandle *) loadHandle;
Tcl_PackageInitProc *proc = NULL;
const char *errMsg = NULL;
Tcl_DString ds;
const char *native;
native = Tcl_UtfToExternalDString(NULL, symbol, -1, &ds);
#if TCL_DYLD_USE_DLFCN
if (dyldLoadHandle->dlHandle) {
proc = dlsym(dyldLoadHandle->dlHandle, native);
if (proc) {
TclLoadDbgMsg("dlsym() successful");
} else {
errMsg = dlerror();
TclLoadDbgMsg("dlsym() failed: %s", errMsg);
}
} else
#endif /* TCL_DYLD_USE_DLFCN */
{
#if TCL_DYLD_USE_NSMODULE || defined(TCL_LOAD_FROM_MEMORY)
NSSymbol nsSymbol = NULL;
Tcl_DString newName;
/*
* dyld adds an underscore to the beginning of symbol names.
*/
Tcl_DStringInit(&newName);
Tcl_DStringAppend(&newName, "_", 1);
native = Tcl_DStringAppend(&newName, native, -1);
if (dyldLoadHandle->dyldLibHeader) {
nsSymbol = NSLookupSymbolInImage(dyldLoadHandle->dyldLibHeader,
native, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW |
NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
if (nsSymbol) {
TclLoadDbgMsg("NSLookupSymbolInImage() successful");
#ifdef DYLD_SUPPORTS_DYLIB_UNLOADING
/*
* Until dyld supports unloading of MY_DYLIB binaries, the
* following is not needed.
*/
NSModule module = NSModuleForSymbol(nsSymbol);
Tcl_DyldModuleHandle *modulePtr = dyldLoadHandle->modulePtr;
while (modulePtr != NULL) {
if (module == modulePtr->module) {
break;
}
modulePtr = modulePtr->nextPtr;
}
if (modulePtr == NULL) {
modulePtr = (Tcl_DyldModuleHandle *)
ckalloc(sizeof(Tcl_DyldModuleHandle));
modulePtr->module = module;
modulePtr->nextPtr = dyldLoadHandle->modulePtr;
dyldLoadHandle->modulePtr = modulePtr;
}
#endif /* DYLD_SUPPORTS_DYLIB_UNLOADING */
} else {
NSLinkEditErrors editError;
int errorNumber;
const char *errorName;
NSLinkEditError(&editError, &errorNumber, &errorName, &errMsg);
TclLoadDbgMsg("NSLookupSymbolInImage() failed: %s", errMsg);
}
} else if (dyldLoadHandle->modulePtr) {
nsSymbol = NSLookupSymbolInModule(
dyldLoadHandle->modulePtr->module, native);
if (nsSymbol) {
TclLoadDbgMsg("NSLookupSymbolInModule() successful");
} else {
TclLoadDbgMsg("NSLookupSymbolInModule() failed");
}
}
if (nsSymbol) {
proc = NSAddressOfSymbol(nsSymbol);
if (proc) {
TclLoadDbgMsg("NSAddressOfSymbol() successful");
} else {
TclLoadDbgMsg("NSAddressOfSymbol() failed");
}
}
Tcl_DStringFree(&newName);
#endif /* TCL_DYLD_USE_NSMODULE */
}
Tcl_DStringFree(&ds);
if (errMsg) {
Tcl_AppendResult(interp, errMsg, NULL);
}
return proc;
}
开发者ID:mgarc729,项目名称:tcl8.4.20_udp,代码行数:99,代码来源:tclLoadDyld.c
示例18: TclpDlopen
MODULE_SCOPE int
TclpDlopen(
Tcl_Interp *interp, /* Used for error reporting. */
Tcl_Obj *pathPtr, /* Name of the file containing the desired
* code (UTF-8). */
Tcl_LoadHandle *loadHandle, /* Filled with token for dynamically loaded
* file which will be passed back to
* (*unloadProcPtr)() to unload the file. */
Tcl_FSUnloadFileProc **unloadProcPtr)
/* Filled with address of Tcl_FSUnloadFileProc
* function which should be used for this
* file. */
{
Tcl_DyldLoadHandle *dyldLoadHandle;
#if TCL_DYLD_USE_DLFCN
void *dlHandle = NULL;
#endif
#if TCL_DYLD_USE_NSMODULE || defined(TCL_LOAD_FROM_MEMORY)
const struct mach_header *dyldLibHeader = NULL;
Tcl_DyldModuleHandle *modulePtr = NULL;
#endif
#if TCL_DYLD_USE_NSMODULE
NSLinkEditErrors editError;
int errorNumber;
const char *errorName, *objFileImageErrMsg = NULL;
#endif
const char *errMsg = NULL;
int result;
Tcl_DString ds;
char *fileName = NULL;
const char *nativePath, *nativeFileName = NULL;
/*
* First try the full path the user gave us. This is particularly
* important if the cwd is inside a vfs, and we are trying to load using a
* relative path.
*/
nativePath = Tcl_FSGetNativePath(pathPtr);
#if TCL_DYLD_USE_DLFCN
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
if (tclMacOSXDarwinRelease >= 8)
#endif
{
dlHandle = dlopen(nativePath, RTLD_NOW | RTLD_LOCAL);
if (!dlHandle) {
/*
* Let the OS loader examine the binary search path for whatever
* string the user gave us which hopefully refers to a file on the
* binary path.
*/
fileName = Tcl_GetString(pathPtr);
nativeFileName = Tcl_UtfToExternalDString(NULL, fileName, -1, &ds);
dlHandle = dlopen(nativeFileName, RTLD_NOW | RTLD_LOCAL);
}
if (dlHandle) {
TclLoadDbgMsg("dlopen() successful");
} else {
errMsg = dlerror();
TclLoadDbgMsg("dlopen() failed: %s", errMsg);
}
}
if (!dlHandle)
#endif /* TCL_DYLD_USE_DLFCN */
{
#if TCL_DYLD_USE_NSMODULE
dyldLibHeader = NSAddImage(nativePath,
NSADDIMAGE_OPTION_RETURN_ON_ERROR);
if (dyldLibHeader) {
TclLoadDbgMsg("NSAddImage() successful");
} else {
NSLinkEditError(&editError, &errorNumber, &errorName, &errMsg);
if (editError == NSLinkEditFileAccessError) {
/*
* The requested file was not found. Let the OS loader examine
* the binary search path for whatever string the user gave us
* which hopefully refers to a file on the binary path.
*/
if (!fileName) {
fileName = Tcl_GetString(pathPtr);
nativeFileName = Tcl_UtfToExternalDString(NULL, fileName,
-1, &ds);
}
dyldLibHeader = NSAddImage(nativeFileName,
NSADDIMAGE_OPTION_WITH_SEARCHING |
NSADDIMAGE_OPTION_RETURN_ON_ERROR);
if (dyldLibHeader) {
TclLoadDbgMsg("NSAddImage() successful");
} else {
NSLinkEditError(&editError, &errorNumber, &errorName,
&errMsg);
TclLoadDbgMsg("NSAddImage() failed: %s", errMsg);
}
} else if ((editError == NSLinkEditFileFormatError
&& errorNumber == EBADMACHO)
|| editError == NSLinkEditOtherError){
NSObjectFileImageReturnCode err;
//.........这里部分代码省略.........
开发者ID:mgarc729,项目名称:tcl8.4.20_udp,代码行数:101,代码来源:tclLoadDyld.c
示例19: UnicodeStringToMultiByte
bool CLibrary::Load(LPCTSTR lpLibFileName)
{
if(!Free())
return false;
void *handler = 0;
char name[MAX_PATHNAME_LEN+1];
#ifdef _UNICODE
AString name2 = UnicodeStringToMultiByte(lpLibFileName);
strcpy(name,nameWindowToUnix((const char *)name2));
#else
strcpy(name,nameWindowToUnix(lpLibFileName));
#endif
// replace ".dll" with ".so"
size_t len = strlen(name);
if ((len >=4) && (strcmp(name+len-4,".dll") == 0)) {
strcpy(name+len-4,".so");
}
#ifdef __ANDROID__
char tmp[MAX_PATHNAME_LEN+1];
if (strncmp(name, "./", 2) == 0) {
strcpy(tmp, name+2);
sprintf(name, "lib%s", tmp);
}
#endif
TRACEN((printf("CLibrary::Load(this=%p,%ls) => %s\n",(void *)this,lpLibFileName,name)))
#ifdef __APPLE_CC__
NSObjectFileImage image;
NSObjectFileImageReturnCode nsret;
nsret = NSCreateObjectFileImageFromFile (name, &image);
if (nsret == NSObjectFileImageSuccess) {
TRACEN((printf("NSCreateObjectFileImageFromFile(%s) : OK\n",name)))
handler = (HMODULE)NSLinkModule(image,name,NSLINKMODULE_OPTION_RETURN_ON_ERROR
| NSLINKMODULE_OPTION_PRIVATE | NSLINKMODULE_OPTION_BINDNOW);
} else {
TRACEN((printf("NSCreateObjectFileImageFromFile(%s) : ERROR\n",name)))
}
#elif ENV_BEOS
// normalize path (remove things like "./", "..", etc..), otherwise it won't work
BPath p(name, NULL, true);
status_t err = B_OK;
image_id image = load_add_on(p.Path());
TRACEN((printf("load_add_on(%s)=%d\n",p.Path(),(int)image)))
if (image < 0) {
err = (image_id)handler;
handler = 0;
} else {
err = 0;
handler = (HMODULE)image;
}
#else
int options_dlopen = 0;
#ifdef RTLD_LOCAL
options_dlopen |= RTLD_LOCAL;
#endif
#ifdef RTLD_NOW
options_dlopen |= RTLD_NOW;
#endif
#ifdef RTLD_GROUP
#if ! (defined(hpux) || defined(__hpux))
options_dlopen |= RTLD_GROUP; // mainly for solaris but not for HPUX
#endif
#endif
TRACEN((printf("CLibrary::Load - dlopen(%s,0x%d)\n",name,options_dlopen)))
handler = dlopen(name,options_dlopen);
#endif // __APPLE_CC__
TRACEN((printf("CLibrary::Load(%s) => %p\n",name,handler)))
if (handler) {
// Call DllMain() like in Windows : useless now
// Propagate the value of global_use_utf16_conversion into the plugins
int *tmp = (int *)local_GetProcAddress(handler,"global_use_utf16_conversion");
if (tmp) *tmp = global_use_utf16_conversion;
#ifdef ENV_HAVE_LSTAT
tmp = (int *)local_GetProcAddress(handler,"global_use_lstat");
if (tmp) *tmp = global_use_lstat;
#endif
// test construtors calls
void (*fctTest)(void) = (void (*)(void))local_GetProcAddress(handler,"sync_TestConstructor");
if (fctTest) fctTest();
} else {
#ifdef __APPLE_CC__
NSLinkEditErrors c;
int num_err;
const char *file,*err;
NSLinkEditError(&c,&num_err,&file,&err);
printf("Can't load '%ls' (%s)\n", lpLibFileName,err);
#elif ENV_BEOS
printf("Can't load '%ls' (%s)\n", lpLibFileName,strerror(err));
#else
printf("Can't load '%ls' (%s)\n", lpLibFileName,dlerror());
#endif
}
//.........这里部分代码省略.........
开发者ID:liupeng110,项目名称:p7zip-android,代码行数:101,代码来源:DLL.cpp
示例20: _PyImport_GetDynLoadFunc
dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
const char *pathname, FILE *fp)
{
dl_funcptr p = NULL;
char funcname[258];
NSObjectFileImageReturnCode rc;
NSObjectFileImage image;
NSModule newModule;
NSSymbol theSym;
const char *errString;
char errBuf[512];
PyOS_snprintf(funcname, sizeof(funcname), "_init%.200s", shortname);
#ifdef USE_DYLD_GLOBAL_NAMESPACE
if (NSIsSymbolNameDefined(funcname)) {
theSym = NSLookupAndBindSymbol(funcname);
p = (dl_funcptr)NSAddressOfSymbol(theSym);
return p;
}
#endif
rc = NSCreateObjectFileImageFromFile(pathname, &image);
switch(rc) {
default:
case NSObjectFileImageFailure:
case NSObjectFileImageFormat:
/* for these a message is printed on stderr by dyld */
errString = "Can't create object file image";
break;
case NSObjectFileImageSuccess:
errString = NULL;
break;
case NSObjectFileImageInappropriateFile:
errString = "Inappropriate file type for dynamic loading";
break;
case NSObjectFileImageArch:
errString = "Wrong CPU type in object file";
break;
case NSObjectFileImageAccess:
errString = "Can't read object file (no access)";
break;
}
if (errString == NULL) {
newModule = NSLinkModule(image, pathname, LINKOPTIONS);
if (newModule == NULL) {
int errNo;
const char *fileName, *moreErrorStr;
NSLinkEditErrors c;
NSLinkEditError( &c, &errNo, &fileName, &moreErrorStr );
PyOS_snprintf(errBuf, 512, "Failure linking new module: %s: %s",
fileName, moreErrorStr);
errString = errBuf;
}
}
if (errString != NULL) {
PyErr_SetString(PyExc_ImportError, errString);
return NULL;
}
#ifdef USE_DYLD_GLOBAL_NAMESPACE
if (!NSIsSymbolNameDefined(funcname)) {
/* UnlinkModule() isn't implemented in current versions, but calling it does no harm */
NSUnLinkModule(newModule, FALSE);
PyErr_Format(PyExc_ImportError,
"Loaded module does not contain symbol %.200s",
funcname);
return NULL;
}
theSym = NSLookupAndBindSymbol(funcname);
#else
theSym = NSLookupSymbolInModule(newModule, funcname);
if ( theSym == NULL ) {
NSUnLinkModule(newModule, FALSE);
PyErr_Format(PyExc_ImportError,
"Loaded module does not contain symbol %.200s",
funcname);
return NULL;
}
#endif
p = (dl_funcptr)NSAddressOfSymbol(theSym);
return p;
}
开发者ID:Belxjander,项目名称:Kirito,代码行数:81,代码来源:dynload_next.c
注:本文中的NSLinkEditError函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论