Beispiel #1
0
static void
dlthreadinit(void)

{
    dlts_t * p;

    if (!(dlflags & INITED))
        dlinit();

    if (dlflags & MULTIBUF) {
        p = pthread_getspecific(dlkey);

        if (!p) {
            p = (dlts_t *) malloc(sizeof *p);

            if (p) {
                p->lockcount = 0;
                p->iserror = 0;

                if (pthread_setspecific(dlkey, p))
                    free(p);
            }
        }
    }
}
static void *dlopen(const char *path, int mode)
{
  void			*handle= 0;
  NSObjectFileImage	 ofi= 0;

  if (!dlInitialised)
    {
      dlinit();
      dlInitialised= 1;
    }

  if (!path)
    return DL_APP_CONTEXT;

  switch (NSCreateObjectFileImageFromFile(path, &ofi))
    {
    case NSObjectFileImageSuccess:
      handle= NSLinkModule(ofi, path, NSLINKMODULE_OPTION_RETURN_ON_ERROR);
      NSDestroyObjectFileImage(ofi);
      break;
    case NSObjectFileImageInappropriateFile:
      handle= (void *)NSAddImage(path, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
      break;
    default:
      handle= 0;
      break;
    }

  if (!handle)
    dlSetError("could not load shared object: %s", path);

  dprintf((stderr, "dlopen: %s => %d\n", path, (int)handle));

  return handle;
}
Beispiel #3
0
int main()
{
  void *module,*fun;
  if (!dlinit()) {
    fprintf(stderr, "dlinit() failed.\n");
    exit(1);
  }
  module=dlopen("./myconftest.so",RTLD_NOW);
  if(!module)
  {
    fprintf(stderr,"Failed to link myconftest.so: %s\n",dlerror());
    exit(1);
  }
  fun=dlsym(module,"testfunc");
  if(!fun) fun=dlsym(module,"_testfunc");
  if(!fun)
  {
    fprintf(stderr,"Failed to find function testfunc: %s\n",dlerror());
    exit(1);
  }
  fprintf(stderr,"Calling testfunc\n");
  ((void (*)(void))fun)();
  fprintf(stderr,"testfunc returned!\n");
  exit(1);
}
Beispiel #4
0
int main(int argc, const char **argv) {
    // The simulator needs this call to enable dlopen to work...
    char libgcc[] = "libgcc.so";
    char libc[] = "libc.so";
    char libstdcpp[] = "libstdc++.so";
    char *builtin[] = {libgcc, libc, libstdcpp};
    dlinit(3, builtin);

    while(true) {
        switch (rpc_call) {
        case Message::None:
            break;
        case Message::Alloc:
            set_rpc_return(reinterpret_cast<int>(memalign(hvx_alignment, RPC_ARG(0))));
            break;
        case Message::Free:
            free(reinterpret_cast<void*>(RPC_ARG(0)));
            set_rpc_return(0);
            break;
        case Message::InitKernels:
            set_rpc_return(initialize_kernels(
                               reinterpret_cast<unsigned char*>(RPC_ARG(0)),
                               RPC_ARG(1),
                               reinterpret_cast<handle_t*>(RPC_ARG(2))));
            break;
        case Message::GetSymbol:
            set_rpc_return(get_symbol(
                               static_cast<handle_t>(RPC_ARG(0)),
                               reinterpret_cast<const char *>(RPC_ARG(1)),
                               RPC_ARG(2)));
            break;
        case Message::Run:
            set_rpc_return(run(
                               static_cast<handle_t>(RPC_ARG(0)),
                               static_cast<handle_t>(RPC_ARG(1)),
                               reinterpret_cast<const buffer*>(RPC_ARG(2)),
                               RPC_ARG(3),
                               reinterpret_cast<buffer*>(RPC_ARG(4)),
                               RPC_ARG(5),
                               reinterpret_cast<const buffer*>(RPC_ARG(6)),
                               RPC_ARG(7)));
            break;
        case Message::ReleaseKernels:
            set_rpc_return(release_kernels(
                               static_cast<handle_t>(RPC_ARG(0)),
                               RPC_ARG(1)));
            break;
        case Message::Break:
            return 0;
        default:
            log_printf("Unknown message: %d\n", rpc_call);
            return -1;
        }
    }
    log_printf("Unreachable!\n");
    return 0;
}
Beispiel #5
0
void init_dynamic_load(void)
{
#ifdef USE_DYNAMIC_MODULES
  if (dlinit()) {
  
    /* function(string:program) */

    ADD_EFUN("load_module", f_load_module,
	     tFunc(tStr,tPrg(tObj)), OPT_EXTERNAL_DEPEND);
  }
#endif
}
Beispiel #6
0
static void dllib_init() {
    // The simulator needs this call to enable dlopen to work...
    const char *builtin[] = {"libgcc.so", "libc.so", "libstdc++.so"};
    dlinit(3, const_cast<char**>(builtin));
}