Exemplo n.º 1
0
/* We found two symbols for the same name in two different modules */
static NSModule multiple(NSSymbol s, NSModule om, NSModule nm)
{
    NSModule ret = nm;

    log_debug("Symbol \"%s\" found in modules \"%s\" and \"%s\" (using %s)",
              NSNameOfSymbol(s), NSNameOfModule(om), NSNameOfModule(nm),
              NSNameOfModule(ret));

    return (ret);
}
Exemplo n.º 2
0
NSModule multipleErrorHandler(NSSymbol s, NSModule old, NSModule newmod)
{
  /* XXX
  ** This results in substantial leaking of memory... Should free one
  ** module, maybe?
  */
  fprintf(stderr, "%s: Symbol `%s' found in `%s' and `%s'",
                       __FILE__, NSNameOfSymbol(s), NSNameOfModule(old), NSNameOfModule(newmod));
  
  return(newmod);
}
Exemplo n.º 3
0
int dlclose(void *handle)
{
  if (is_mach_header(handle))
  {
    error(0, "Can't remove dynamic libraries on darwin");
    return 0;
  }
  if (!NSUnLinkModule((NSModule)handle, 0))
  {
    error(0, "unable to unlink module %s", NSNameOfModule((NSModule)handle));
    return 1;
  }
  return 0;
}
static int dlclose(void *handle)
{
  if ((  (MH_MAGIC == ((struct mach_header *)handle)->magic))	/* ppc */
      || (MH_CIGAM == ((struct mach_header *)handle)->magic))	/* 386 */
    return 0;	/* can't unlink, but pretend we did */

  if (!NSUnLinkModule(handle, 0))
    {
      dlSetError("could not unlink shared object: %s", NSNameOfModule(handle));
      return -1;
    }

  return 0;
}
Exemplo n.º 5
0
int dlclose(void *handle)
{
	if ((((struct mach_header *)handle)->magic == MH_MAGIC) ||
		(((struct mach_header *)handle)->magic == MH_CIGAM))
	{
		error(-1, "Can't remove dynamic libraries on darwin");
		return 0;
	}
	if (!NSUnLinkModule(handle, 0))
	{
		error(0, "unable to unlink module %s", NSNameOfModule(handle));
		return 1;
	}
	return 0;
}
Exemplo n.º 6
0
/* Returns the mach_header for the module bu going through all the loaded images
 * and finding the one with the same name as the module. There really ought to be
 * an api for doing this, would be faster, but there isn't one right now
 */
static const struct mach_header *get_mach_header_from_NSModule(NSModule * mod)
{
	const char *mod_name = NSNameOfModule(mod);
	struct mach_header *mh = NULL;
	unsigned long count = _dyld_image_count();
	unsigned long i;
	debug("Module name: %s", mod_name);
	for (i = 0; i < count; i++)
	{
		if (!strcmp(mod_name, _dyld_get_image_name(i)))
		{
			mh = _dyld_get_image_header(i);
			break;
		}
	}
	return mh;
}
Exemplo n.º 7
0
/* Get the address for a specifed symbol */
void *dso_symbol(dso_handle hdl, const char *nam)
{
    NSSymbol sym = NULL;
    NSModule mod = NULL;
    char *und = NULL;
    void *add = NULL;
    int x = 0;

    /* Check parameters */
    if (hdl == NULL) {
        log_error("Invalid library handler specified");
        return (NULL);
    }

    if (nam == NULL) {
        log_error("Invalid symbol name specified");
        return (NULL);
    }

    /* Process the correct name (add a _ before the name) */
    while (nam[x] != '\0')
        x++;
    und = (char *)malloc(sizeof(char) * (x + 2));
    while (x >= 0)
        und[x + 1] = nam[x--];
    und[0] = '_';

    /* Find the symbol */
    sym = NSLookupAndBindSymbol(und);
    free(und);
    if (sym == NULL)
        return (NULL);

    /* Dump some debugging output since this part is shaky */
    mod = NSModuleForSymbol(sym);
    add = NSAddressOfSymbol(sym);
    log_debug("Symbol \"%s\" found in module \"%s\" at address \"0x%08X\"",
              NSNameOfSymbol(sym), NSNameOfModule(mod), add);

    /* We want to return the address of the symbol */
    return (add);
}
Exemplo n.º 8
0
/* There should probably be an apple dyld api for this. */
static const mach_header *
lt__nsmodule_get_header (NSModule module)
{
  int i = _dyld_image_count();
  const char *modname = NSNameOfModule (module);
  const mach_header *mh = 0;

  if (!modname)
    return NULL;

  while (i > 0)
    {
      --i;
      if (strneq (_dyld_get_image_name (i), modname))
	{
	  mh = _dyld_get_image_header (i);
	  break;
	}
    }

  return mh;
}
static NSModule dlMultiple(NSSymbol s, NSModule oldModule, NSModule newModule)
{
  dprintf((stderr, "dyld: %s: %s previously defined in %s, new definition in %s\n",
	   NSNameOfSymbol(s), NSNameOfModule(oldModule), NSNameOfModule(newModule)));
  return newModule;
}
Exemplo n.º 10
0
ap_private_extern
NSModule multiple_symbol_handler (NSSymbol s, NSModule old, NSModule new)
{
    /*
     * Since we can't unload symbols, we're going to run into this
     * every time we reload a module. Workaround here is to just
     * rebind to the new symbol, and forget about the old one.
     * This is crummy, because it's basically a memory leak.
     */

#ifdef DEBUG
    ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_DEBUG, NULL,
                 "dyld found a multiply defined symbol %s in modules:\n"
                 "%s\n%s\n",
                 NSNameOfSymbol(s),
                 NSNameOfModule(old), NSNameOfModule(new));
#endif

    return(new);
}

ap_private_extern
void linkEdit_symbol_handler (NSLinkEditErrors c, int errorNumber,
                              const char *fileName, const char *errorString)
{
    ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, NULL,
                 "dyld errors during link edit for file %s\n%s\n",
                 fileName, errorString);
    abort();
}