Lines Matching refs:mod

156 apply_imm64 (struct module *mod, struct insn *insn, uint64_t val)  in apply_imm64()  argument
160 mod->name, slot(insn)); in apply_imm64()
168 apply_imm60 (struct module *mod, struct insn *insn, uint64_t val) in apply_imm60() argument
172 mod->name, slot(insn)); in apply_imm60()
177 mod->name, (long) val); in apply_imm60()
185 apply_imm22 (struct module *mod, struct insn *insn, uint64_t val) in apply_imm22() argument
189 mod->name, (long)val); in apply_imm22()
200 apply_imm21b (struct module *mod, struct insn *insn, uint64_t val) in apply_imm21b() argument
204 mod->name, (long)val); in apply_imm21b()
235 patch_plt (struct module *mod, struct plt_entry *plt, long target_ip, unsigned long target_gp) in patch_plt() argument
237 if (apply_imm64(mod, (struct insn *) (plt->bundle[0] + 2), target_gp) in patch_plt()
238 && apply_imm60(mod, (struct insn *) (plt->bundle[1] + 2), in patch_plt()
285 patch_plt (struct module *mod, struct plt_entry *plt, long target_ip, unsigned long target_gp) in patch_plt() argument
287 if (apply_imm64(mod, (struct insn *) (plt->bundle[0] + 2), target_ip) in patch_plt()
288 && apply_imm64(mod, (struct insn *) (plt->bundle[1] + 2), target_gp)) in patch_plt()
310 module_arch_freeing_init (struct module *mod) in module_arch_freeing_init() argument
312 if (mod->arch.init_unw_table) { in module_arch_freeing_init()
313 unw_remove_unwind_table(mod->arch.init_unw_table); in module_arch_freeing_init()
314 mod->arch.init_unw_table = NULL; in module_arch_freeing_init()
424 struct module *mod) in module_frob_arch_sections() argument
435 mod->arch.core_plt = s; in module_frob_arch_sections()
437 mod->arch.init_plt = s; in module_frob_arch_sections()
439 mod->arch.got = s; in module_frob_arch_sections()
441 mod->arch.opd = s; in module_frob_arch_sections()
443 mod->arch.unwind = s; in module_frob_arch_sections()
445 if (!mod->arch.core_plt || !mod->arch.init_plt || !mod->arch.got || !mod->arch.opd) { in module_frob_arch_sections()
446 printk(KERN_ERR "%s: sections missing\n", mod->name); in module_frob_arch_sections()
466 mod->arch.core_plt->sh_type = SHT_NOBITS; in module_frob_arch_sections()
467 mod->arch.core_plt->sh_flags = SHF_EXECINSTR | SHF_ALLOC; in module_frob_arch_sections()
468 mod->arch.core_plt->sh_addralign = 16; in module_frob_arch_sections()
469 mod->arch.core_plt->sh_size = core_plts * sizeof(struct plt_entry); in module_frob_arch_sections()
470 mod->arch.init_plt->sh_type = SHT_NOBITS; in module_frob_arch_sections()
471 mod->arch.init_plt->sh_flags = SHF_EXECINSTR | SHF_ALLOC; in module_frob_arch_sections()
472 mod->arch.init_plt->sh_addralign = 16; in module_frob_arch_sections()
473 mod->arch.init_plt->sh_size = init_plts * sizeof(struct plt_entry); in module_frob_arch_sections()
474 mod->arch.got->sh_type = SHT_NOBITS; in module_frob_arch_sections()
475 mod->arch.got->sh_flags = ARCH_SHF_SMALL | SHF_ALLOC; in module_frob_arch_sections()
476 mod->arch.got->sh_addralign = 8; in module_frob_arch_sections()
477 mod->arch.got->sh_size = gots * sizeof(struct got_entry); in module_frob_arch_sections()
478 mod->arch.opd->sh_type = SHT_NOBITS; in module_frob_arch_sections()
479 mod->arch.opd->sh_flags = SHF_ALLOC; in module_frob_arch_sections()
480 mod->arch.opd->sh_addralign = 8; in module_frob_arch_sections()
481 mod->arch.opd->sh_size = fdescs * sizeof(struct fdesc); in module_frob_arch_sections()
483 __func__, mod->arch.core_plt->sh_size, mod->arch.init_plt->sh_size, in module_frob_arch_sections()
484 mod->arch.got->sh_size, mod->arch.opd->sh_size); in module_frob_arch_sections()
489 in_init (const struct module *mod, uint64_t addr) in in_init() argument
491 return within_module_init(addr, mod); in in_init()
495 in_core (const struct module *mod, uint64_t addr) in in_core() argument
497 return within_module_core(addr, mod); in in_core()
501 is_internal (const struct module *mod, uint64_t value) in is_internal() argument
503 return in_init(mod, value) || in_core(mod, value); in is_internal()
510 get_ltoff (struct module *mod, uint64_t value, int *okp) in get_ltoff() argument
517 got = (void *) mod->arch.got->sh_addr; in get_ltoff()
518 for (e = got; e < got + mod->arch.next_got_entry; ++e) in get_ltoff()
523 BUG_ON(e >= (struct got_entry *) (mod->arch.got->sh_addr + mod->arch.got->sh_size)); in get_ltoff()
526 ++mod->arch.next_got_entry; in get_ltoff()
528 return (uint64_t) e - mod->arch.gp; in get_ltoff()
532 gp_addressable (struct module *mod, uint64_t value) in gp_addressable() argument
534 return value - mod->arch.gp + MAX_LTOFF/2 < MAX_LTOFF; in gp_addressable()
539 get_plt (struct module *mod, const struct insn *insn, uint64_t value, int *okp) in get_plt() argument
547 if (in_init(mod, (uint64_t) insn)) { in get_plt()
548 plt = (void *) mod->arch.init_plt->sh_addr; in get_plt()
549 plt_end = (void *) plt + mod->arch.init_plt->sh_size; in get_plt()
551 plt = (void *) mod->arch.core_plt->sh_addr; in get_plt()
552 plt_end = (void *) plt + mod->arch.core_plt->sh_size; in get_plt()
567 if (!patch_plt(mod, plt, target_ip, target_gp)) { in get_plt()
585 get_fdesc (struct module *mod, uint64_t value, int *okp) in get_fdesc() argument
587 struct fdesc *fdesc = (void *) mod->arch.opd->sh_addr; in get_fdesc()
593 printk(KERN_ERR "%s: fdesc for zero requested!\n", mod->name); in get_fdesc()
597 if (!is_internal(mod, value)) in get_fdesc()
608 if ((uint64_t) ++fdesc >= mod->arch.opd->sh_addr + mod->arch.opd->sh_size) in get_fdesc()
614 fdesc->gp = mod->arch.gp; in get_fdesc()
619 do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend, in do_reloc() argument
634 case RV_GPREL: val -= mod->arch.gp; break; in do_reloc()
635 case RV_LTREL: val = get_ltoff(mod, val, &ok); break; in do_reloc()
636 case RV_PLTREL: val = get_plt(mod, location, val, &ok); break; in do_reloc()
637 case RV_FPTR: val = get_fdesc(mod, val, &ok); break; in do_reloc()
639 case RV_LTREL_FPTR: val = get_ltoff(mod, get_fdesc(mod, val, &ok), &ok); break; in do_reloc()
644 if ((in_init(mod, val) && in_core(mod, (uint64_t)location)) || in do_reloc()
645 (in_core(mod, val) && in_init(mod, (uint64_t)location))) { in do_reloc()
652 val = get_fdesc(mod, val, &ok); in do_reloc()
653 val = get_plt(mod, location, val, &ok); in do_reloc()
655 } else if (!is_internal(mod, val)) in do_reloc()
656 val = get_plt(mod, location, val, &ok); in do_reloc()
680 val -= (uint64_t) (in_init(mod, val) ? mod->mem[MOD_INIT_TEXT].base : in do_reloc()
681 mod->mem[MOD_TEXT].base); in do_reloc()
691 if (!is_internal(mod, val)) { in do_reloc()
706 val = get_fdesc(mod, get_plt(mod, location, val, &ok), &ok); in do_reloc()
718 if (gp_addressable(mod, val)) in do_reloc()
719 val -= mod->arch.gp; in do_reloc()
721 val = get_ltoff(mod, val, &ok); in do_reloc()
726 if (gp_addressable(mod, val)) { in do_reloc()
736 mod->name, reloc_name[r_type]); in do_reloc()
739 mod->name, r_type); in do_reloc()
751 mod->name, reloc_name[r_type] ? reloc_name[r_type] : "?"); in do_reloc()
755 printk(KERN_ERR "%s: unknown reloc %x\n", mod->name, r_type); in do_reloc()
766 case RF_INSN21B: ok = apply_imm21b(mod, location, (int64_t) val / 16); break; in do_reloc()
767 case RF_INSN22: ok = apply_imm22(mod, location, val); break; in do_reloc()
768 case RF_INSN64: ok = apply_imm64(mod, location, val); break; in do_reloc()
769 case RF_INSN60: ok = apply_imm60(mod, location, (int64_t) val / 16); break; in do_reloc()
778 mod->name, format, reloc_name[r_type] ? reloc_name[r_type] : "?"); in do_reloc()
783 mod->name, reloc_name[r_type] ? reloc_name[r_type] : "?", format); in do_reloc()
791 unsigned int relsec, struct module *mod) in apply_relocate_add() argument
810 if (!mod->arch.gp) { in apply_relocate_add()
818 mod_mem = &mod->mem[MOD_DATA]; in apply_relocate_add()
828 mod->arch.gp = gp; in apply_relocate_add()
833 ret = do_reloc(mod, ELF64_R_TYPE(rela[i].r_info), in apply_relocate_add()
851 register_unwind_table (struct module *mod) in register_unwind_table() argument
853 struct unw_table_entry *start = (void *) mod->arch.unwind->sh_addr; in register_unwind_table()
854 struct unw_table_entry *end = start + mod->arch.unwind->sh_size / sizeof (*start); in register_unwind_table()
860 if (in_init(mod, e1->start_offset)) in register_unwind_table()
879 if (in_init(mod, start->start_offset)) { in register_unwind_table()
888 mod->name, mod->arch.gp, num_init, num_core); in register_unwind_table()
894 mod->arch.core_unw_table = unw_add_unwind_table(mod->name, 0, mod->arch.gp, in register_unwind_table()
897 mod->arch.core_unw_table, core, core + num_core); in register_unwind_table()
900 mod->arch.init_unw_table = unw_add_unwind_table(mod->name, 0, mod->arch.gp, in register_unwind_table()
903 mod->arch.init_unw_table, init, init + num_init); in register_unwind_table()
908 module_finalize (const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs, struct module *mod) in module_finalize() argument
910 struct mod_arch_specific *mas = &mod->arch; in module_finalize()
912 DEBUGP("%s: init: entry=%p\n", __func__, mod->init); in module_finalize()
914 register_unwind_table(mod); in module_finalize()
939 module_arch_cleanup (struct module *mod) in module_arch_cleanup() argument
941 if (mod->arch.init_unw_table) { in module_arch_cleanup()
942 unw_remove_unwind_table(mod->arch.init_unw_table); in module_arch_cleanup()
943 mod->arch.init_unw_table = NULL; in module_arch_cleanup()
945 if (mod->arch.core_unw_table) { in module_arch_cleanup()
946 unw_remove_unwind_table(mod->arch.core_unw_table); in module_arch_cleanup()
947 mod->arch.core_unw_table = NULL; in module_arch_cleanup()
951 void *dereference_module_function_descriptor(struct module *mod, void *ptr) in dereference_module_function_descriptor() argument
953 struct mod_arch_specific *mas = &mod->arch; in dereference_module_function_descriptor()