Lines Matching refs:module
50 extern int load_segments(struct elf_module *module, Elf_Ehdr *elf_hdr);
52 static int prepare_dynlinking(struct elf_module *module) { in prepare_dynlinking() argument
53 Elf_Dyn *dyn_entry = module->dyn_table; in prepare_dynlinking()
64 if (module->nr_needed < MAX_NR_DEPS) in prepare_dynlinking()
65 module->needed[module->nr_needed++] = dyn_entry->d_un.d_ptr; in prepare_dynlinking()
72 module->hash_table = in prepare_dynlinking()
73 (Elf_Word*)module_get_absolute(dyn_entry->d_un.d_ptr, module); in prepare_dynlinking()
76 module->ghash_table = in prepare_dynlinking()
77 (Elf_Word*)module_get_absolute(dyn_entry->d_un.d_ptr, module); in prepare_dynlinking()
80 module->str_table = in prepare_dynlinking()
81 (char*)module_get_absolute(dyn_entry->d_un.d_ptr, module); in prepare_dynlinking()
84 module->sym_table = in prepare_dynlinking()
85 module_get_absolute(dyn_entry->d_un.d_ptr, module); in prepare_dynlinking()
88 module->strtable_size = dyn_entry->d_un.d_val; in prepare_dynlinking()
91 module->syment_size = dyn_entry->d_un.d_val; in prepare_dynlinking()
94 module->got = module_get_absolute(dyn_entry->d_un.d_ptr, module); in prepare_dynlinking()
110 extern int perform_relocation(struct elf_module *module, Elf_Rel *rel);
111 extern int resolve_symbols(struct elf_module *module);
113 static int extract_operations(struct elf_module *module) { in extract_operations() argument
119 ctors_start = module_find_symbol("__ctors_start", module); in extract_operations()
120 ctors_end = module_find_symbol("__ctors_end", module); in extract_operations()
127 start = module_get_absolute(ctors_start->st_value, module); in extract_operations()
128 end = module_get_absolute(ctors_end->st_value, module); in extract_operations()
145 module->ctors = ctors; in extract_operations()
148 dtors_start = module_find_symbol("__dtors_start", module); in extract_operations()
149 dtors_end = module_find_symbol("__dtors_end", module); in extract_operations()
156 start = module_get_absolute(dtors_start->st_value, module); in extract_operations()
157 end = module_get_absolute(dtors_end->st_value, module); in extract_operations()
175 module->dtors = dtors; in extract_operations()
182 int module_load(struct elf_module *module) { in module_load() argument
190 if (module_find(module->name) != NULL) { in module_load()
191 dprintf("Module %s is already loaded.\n", module->name); in module_load()
196 res = image_load(module); in module_load()
199 dprintf("Image load failed for %s\n", module->name); in module_load()
204 module->shallow = 0; in module_load()
206 CHECKED(res, image_read(&elf_hdr, sizeof(Elf_Ehdr), module), error); in module_load()
216 CHECKED(res, load_segments(module, &elf_hdr), error); in module_load()
219 CHECKED(res, prepare_dynlinking(module), error); in module_load()
225 if (module->str_table) { in module_load()
232 for (i = module->nr_needed - 1; i >= 0; i--) { in module_load()
236 dep = module->str_table + module->needed[i]; in module_load()
258 CHECKED(res, check_symbols(module), error); in module_load()
261 main_sym = module_find_symbol("main", module); in module_load()
263 module->main_func = in module_load()
264 module_get_absolute(main_sym->st_value, module); in module_load()
269 list_add(&module->list, &modules_head); in module_load()
272 resolve_symbols(module); in module_load()
275 CHECKED(res, extract_operations(module), error); in module_load()
282 image_unload(module); in module_load()
292 for (ctor = module->ctors; ctor && *ctor; ctor++) in module_load()
302 list_del_init(&module->list); in module_load()
304 if (module->module_addr != NULL) { in module_load()
305 elf_free(module->module_addr); in module_load()
306 module->module_addr = NULL; in module_load()
309 image_unload(module); in module_load()
312 memset(&module->u, 0, sizeof module->u); in module_load()