Lines Matching refs:module

46 void print_elf_symbols(struct elf_module *module) {  in print_elf_symbols()  argument
50 for (i = 1; i < module->symtable_size/module->syment_size; i++) in print_elf_symbols()
52 crt_sym = (Elf_Sym*)(module->sym_table + i*module->syment_size); in print_elf_symbols()
54 fprintf(stderr,"%s %d\n", module->str_table + crt_sym->st_name, crt_sym->st_value); in print_elf_symbols()
93 int image_load(struct elf_module *module) in image_load() argument
95 module->u.l._file = findpath(module->name); in image_load()
97 if (module->u.l._file == NULL) { in image_load()
98 dprintf("Could not open object file '%s'\n", module->name); in image_load()
102 module->u.l._cr_offset = 0; in image_load()
107 if (module->u.l._file != NULL) { in image_load()
108 fclose(module->u.l._file); in image_load()
109 module->u.l._file = NULL; in image_load()
116 int image_unload(struct elf_module *module) { in image_unload() argument
117 if (module->u.l._file != NULL) { in image_unload()
118 fclose(module->u.l._file); in image_unload()
119 module->u.l._file = NULL; in image_unload()
122 module->u.l._cr_offset = 0; in image_unload()
127 int image_read(void *buff, size_t size, struct elf_module *module) { in image_read() argument
128 size_t result = fread(buff, size, 1, module->u.l._file); in image_read()
133 module->u.l._cr_offset += size; in image_read()
137 int image_skip(size_t size, struct elf_module *module) { in image_skip() argument
145 result = fread(skip_buff, size, 1, module->u.l._file); in image_skip()
151 module->u.l._cr_offset += size; in image_skip()
155 int image_seek(Elf_Off offset, struct elf_module *module) { in image_seek() argument
156 if (offset < module->u.l._cr_offset) // Cannot seek backwards in image_seek()
159 return image_skip(offset - module->u.l._cr_offset, module); in image_seek()
193 struct module_dep *module_dep_alloc(struct elf_module *module) { in module_dep_alloc() argument
198 result->module = module; in module_dep_alloc()
266 if (crt_dep->module == dep) { in enforce_dependency()
286 if (crt_dep->module == dep) { in clear_dependency()
300 if (crt_dep->module == req) { in clear_dependency()
314 int check_symbols(struct elf_module *module) in check_symbols() argument
324 for (i = 1; i < module->symtable_size/module->syment_size; i++) in check_symbols()
326 crt_sym = symbol_get_entry(module, i); in check_symbols()
327 crt_name = module->str_table + crt_sym->st_name; in check_symbols()
384 int module_unloadable(struct elf_module *module) { in module_unloadable() argument
385 if (!list_empty(&module->dependants)) in module_unloadable()
393 int _module_unload(struct elf_module *module) { in _module_unload() argument
396 if (!module_unloadable(module)) { in _module_unload()
402 list_for_each_entry_safe(crt_dep, tmp, &module->required, list) { in _module_unload()
403 clear_dependency(crt_dep->module, module); in _module_unload()
407 list_del_init(&module->list); in _module_unload()
410 if (module->module_addr != NULL) { in _module_unload()
411 elf_free(module->module_addr); in _module_unload()
413 dprintf("%s MODULE %s UNLOADED\n", module->shallow ? "SHALLOW" : "", in _module_unload()
414 module->name); in _module_unload()
417 dprintf("Unloading module %s\n", module->name); in _module_unload()
419 free(module); in _module_unload()
424 int module_unload(struct elf_module *module) { in module_unload() argument
427 for (dtor = module->dtors; dtor && *dtor; dtor++) in module_unload()
430 return _module_unload(module); in module_unload()
457 static Elf_Sym *module_find_symbol_sysv(const char *name, struct elf_module *module) { in module_find_symbol_sysv() argument
459 Elf_Word *cr_word = module->hash_table; in module_find_symbol_sysv()
467 Elf_Word crt_index = bkt[h % module->hash_table[0]]; in module_find_symbol_sysv()
472 crt_sym = symbol_get_entry(module, crt_index); in module_find_symbol_sysv()
474 if (strcmp(name, module->str_table + crt_sym->st_name) == 0) in module_find_symbol_sysv()
483 static Elf_Sym *module_find_symbol_gnu(const char *name, struct elf_module *module) { in module_find_symbol_gnu() argument
487 Elf_Word *cr_word = module->ghash_table; in module_find_symbol_gnu()
527 Elf_Sym *crt_sym = symbol_get_entry(module, (hasharr - gnu_chain_zero)); in module_find_symbol_gnu()
529 if (strcmp(name, module->str_table + crt_sym->st_name) == 0) { in module_find_symbol_gnu()
540 static Elf_Sym *module_find_symbol_iterate(const char *name,struct elf_module *module) in module_find_symbol_iterate() argument
546 for (i = 1; i < module->symtable_size/module->syment_size; i++) in module_find_symbol_iterate()
548 crt_sym = symbol_get_entry(module, i); in module_find_symbol_iterate()
549 if (strcmp(name, module->str_table + crt_sym->st_name) == 0) in module_find_symbol_iterate()
558 Elf_Sym *module_find_symbol(const char *name, struct elf_module *module) { in module_find_symbol() argument
561 if (module->ghash_table != NULL) in module_find_symbol()
562 result = module_find_symbol_gnu(name, module); in module_find_symbol()
566 if (module->hash_table != NULL) in module_find_symbol()
569 result = module_find_symbol_sysv(name, module); in module_find_symbol()
574 result = module_find_symbol_iterate(name, module); in module_find_symbol()
581 Elf_Sym *global_find_symbol(const char *name, struct elf_module **module) { in global_find_symbol() argument
592 if (module != NULL) { in global_find_symbol()
593 *module = crt_module; in global_find_symbol()
599 if (module != NULL) { in global_find_symbol()
600 *module = crt_module; in global_find_symbol()