Exemple #1
0
void *dlopen(const char *path, int flag)
{
	module_t *m;

	m = module_find(runtime_env, path);
	if (m == NULL) {
		m = module_load(runtime_env, path, mlf_local);
		module_load_deps(m, mlf_local);
		/* Now relocate. */
		module_process_relocs(m);
	}

	return (void *) m;
}
Exemple #2
0
static int ldr_load_dyn_linked(elf_info_t *p_info)
{
	runtime_env = &dload_re;

	DPRINTF("Load dynamically linked program.\n");

	/*
	 * First we need to process dynamic sections of the executable
	 * program and insert it into the module graph.
	 */

	DPRINTF("Parse program .dynamic section at %p\n", p_info->dynamic);
	dynamic_parse(p_info->dynamic, 0, &prog_mod.dyn);
	prog_mod.bias = 0;
	prog_mod.dyn.soname = "[program]";

	/* Initialize list of loaded modules */
	list_initialize(&runtime_env->modules);
	list_append(&prog_mod.modules_link, &runtime_env->modules);

	/* Pointer to program module. Used as root of the module graph. */
	runtime_env->program = &prog_mod;

	/* Work around non-existent memory space allocation. */
	runtime_env->next_bias = 0x1000000;

	/*
	 * Now we can continue with loading all other modules.
	 */

	DPRINTF("Load all program dependencies\n");
	module_load_deps(&prog_mod);

	/*
	 * Now relocate/link all modules together.
	 */

	/* Process relocations in all modules */
	DPRINTF("Relocate all modules\n");
	modules_process_relocs(&prog_mod);

	/* Pass runtime evironment pointer through PCB. */
	pcb.rtld_runtime = (void *) runtime_env;

	return 0;
}