Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
nsGlueLinkingOSX.cpp File Reference
#include "nsGlueLinking.h"
#include "nsXPCOMGlue.h"
#include <mach-o/dyld.h>
#include <sys/param.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

Go to the source code of this file.


static void ReadDependentCB (const char *aDependentLib)
static voidLookupSymbol (const mach_header *aLib, const char *aSymbolName)
GetFrozenFunctionsFunc XPCOMGlueLoad (const char *xpcomFile)
void XPCOMGlueUnload ()
nsresult XPCOMGlueLoadXULFunctions (const nsDynamicFunctionLoad *symbols)


static const mach_header * sXULLibImage

Function Documentation

static void* LookupSymbol ( const mach_header *  aLib,
const char *  aSymbolName 
) [static]

Definition at line 59 of file nsGlueLinkingOSX.cpp.

    // Try to use |NSLookupSymbolInImage| since it is faster than searching
    // the global symbol table.  If we couldn't get a mach_header pointer
    // for the XPCOM dylib, then use |NSLookupAndBindSymbol| to search the
    // global symbol table (this shouldn't normally happen, unless the user
    // has called XPCOMGlueStartup(".") and relies on libxpcom.dylib
    // already being loaded).
    NSSymbol sym = nsnull;
    if (aLib) {
        sym = NSLookupSymbolInImage(aLib, aSymbolName,
                                 NSLOOKUPSYMBOLINIMAGE_OPTION_BIND |
    } else {
        if (NSIsSymbolNameDefined(aSymbolName))
            sym = NSLookupAndBindSymbol(aSymbolName);
    if (!sym)
        return nsnull;

    return NSAddressOfSymbol(sym);

Here is the call graph for this function:

Here is the caller graph for this function:

static void ReadDependentCB ( const char *  aDependentLib) [static]

Definition at line 51 of file nsGlueLinkingOSX.cpp.

    (void) NSAddImage(aDependentLib,

Here is the caller graph for this function:

Definition at line 83 of file nsGlueLinkingOSX.cpp.

    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 |

        lib = NSAddImage(xpcomFile,
                         NSADDIMAGE_OPTION_RETURN_ON_ERROR |
                         NSADDIMAGE_OPTION_WITH_SEARCHING |

    return (GetFrozenFunctionsFunc) LookupSymbol(lib, "_NS_GetFrozenFunctions");

Here is the call graph for this function:

nsresult XPCOMGlueLoadXULFunctions ( const nsDynamicFunctionLoad *  symbols)

Definition at line 121 of file nsGlueLinkingOSX.cpp.

    nsresult rv = NS_OK;
    while (symbols->functionName) {
        char buffer[512];
        snprintf(buffer, sizeof(buffer), "_%s", symbols->functionName);

        *symbols->function = (NSFuncPtr) LookupSymbol(sXULLibImage, buffer);
        if (!*symbols->function)


    return rv;

Here is the call graph for this function:

Definition at line 115 of file nsGlueLinkingOSX.cpp.

  // nothing to do, since we cannot unload dylibs on OS X

Variable Documentation

const mach_header* sXULLibImage [static]

Definition at line 48 of file nsGlueLinkingOSX.cpp.