Lines Matching refs:mod

154 apply_imm64 (struct module *mod, struct insn *insn, uint64_t val)  in apply_imm64()  argument
158 mod->name, slot(insn)); in apply_imm64()
166 apply_imm60 (struct module *mod, struct insn *insn, uint64_t val) in apply_imm60() argument
170 mod->name, slot(insn)); in apply_imm60()
175 mod->name, (long) val); in apply_imm60()
183 apply_imm22 (struct module *mod, struct insn *insn, uint64_t val) in apply_imm22() argument
187 mod->name, (long)val); in apply_imm22()
198 apply_imm21b (struct module *mod, struct insn *insn, uint64_t val) in apply_imm21b() argument
202 mod->name, (long)val); in apply_imm21b()
233 patch_plt (struct module *mod, struct plt_entry *plt, long target_ip, unsigned long target_gp) in patch_plt() argument
235 if (apply_imm64(mod, (struct insn *) (plt->bundle[0] + 2), target_gp) in patch_plt()
236 && apply_imm60(mod, (struct insn *) (plt->bundle[1] + 2), in patch_plt()
283 patch_plt (struct module *mod, struct plt_entry *plt, long target_ip, unsigned long target_gp) in patch_plt() argument
285 if (apply_imm64(mod, (struct insn *) (plt->bundle[0] + 2), target_ip) in patch_plt()
286 && apply_imm64(mod, (struct insn *) (plt->bundle[1] + 2), target_gp)) in patch_plt()
308 module_arch_freeing_init (struct module *mod) in module_arch_freeing_init() argument
310 if (mod->arch.init_unw_table) { in module_arch_freeing_init()
311 unw_remove_unwind_table(mod->arch.init_unw_table); in module_arch_freeing_init()
312 mod->arch.init_unw_table = NULL; in module_arch_freeing_init()
422 struct module *mod) in module_frob_arch_sections() argument
433 mod->arch.core_plt = s; in module_frob_arch_sections()
435 mod->arch.init_plt = s; in module_frob_arch_sections()
437 mod->arch.got = s; in module_frob_arch_sections()
439 mod->arch.opd = s; in module_frob_arch_sections()
441 mod->arch.unwind = s; in module_frob_arch_sections()
443 if (!mod->arch.core_plt || !mod->arch.init_plt || !mod->arch.got || !mod->arch.opd) { in module_frob_arch_sections()
444 printk(KERN_ERR "%s: sections missing\n", mod->name); in module_frob_arch_sections()
464 mod->arch.core_plt->sh_type = SHT_NOBITS; in module_frob_arch_sections()
465 mod->arch.core_plt->sh_flags = SHF_EXECINSTR | SHF_ALLOC; in module_frob_arch_sections()
466 mod->arch.core_plt->sh_addralign = 16; in module_frob_arch_sections()
467 mod->arch.core_plt->sh_size = core_plts * sizeof(struct plt_entry); in module_frob_arch_sections()
468 mod->arch.init_plt->sh_type = SHT_NOBITS; in module_frob_arch_sections()
469 mod->arch.init_plt->sh_flags = SHF_EXECINSTR | SHF_ALLOC; in module_frob_arch_sections()
470 mod->arch.init_plt->sh_addralign = 16; in module_frob_arch_sections()
471 mod->arch.init_plt->sh_size = init_plts * sizeof(struct plt_entry); in module_frob_arch_sections()
472 mod->arch.got->sh_type = SHT_NOBITS; in module_frob_arch_sections()
473 mod->arch.got->sh_flags = ARCH_SHF_SMALL | SHF_ALLOC; in module_frob_arch_sections()
474 mod->arch.got->sh_addralign = 8; in module_frob_arch_sections()
475 mod->arch.got->sh_size = gots * sizeof(struct got_entry); in module_frob_arch_sections()
476 mod->arch.opd->sh_type = SHT_NOBITS; in module_frob_arch_sections()
477 mod->arch.opd->sh_flags = SHF_ALLOC; in module_frob_arch_sections()
478 mod->arch.opd->sh_addralign = 8; in module_frob_arch_sections()
479 mod->arch.opd->sh_size = fdescs * sizeof(struct fdesc); in module_frob_arch_sections()
481 __func__, mod->arch.core_plt->sh_size, mod->arch.init_plt->sh_size, in module_frob_arch_sections()
482 mod->arch.got->sh_size, mod->arch.opd->sh_size); in module_frob_arch_sections()
487 in_init (const struct module *mod, uint64_t addr) in in_init() argument
489 return addr - (uint64_t) mod->module_init < mod->init_size; in in_init()
493 in_core (const struct module *mod, uint64_t addr) in in_core() argument
495 return addr - (uint64_t) mod->module_core < mod->core_size; in in_core()
499 is_internal (const struct module *mod, uint64_t value) in is_internal() argument
501 return in_init(mod, value) || in_core(mod, value); in is_internal()
508 get_ltoff (struct module *mod, uint64_t value, int *okp) in get_ltoff() argument
515 got = (void *) mod->arch.got->sh_addr; in get_ltoff()
516 for (e = got; e < got + mod->arch.next_got_entry; ++e) in get_ltoff()
521 BUG_ON(e >= (struct got_entry *) (mod->arch.got->sh_addr + mod->arch.got->sh_size)); in get_ltoff()
524 ++mod->arch.next_got_entry; in get_ltoff()
526 return (uint64_t) e - mod->arch.gp; in get_ltoff()
530 gp_addressable (struct module *mod, uint64_t value) in gp_addressable() argument
532 return value - mod->arch.gp + MAX_LTOFF/2 < MAX_LTOFF; in gp_addressable()
537 get_plt (struct module *mod, const struct insn *insn, uint64_t value, int *okp) in get_plt() argument
545 if (in_init(mod, (uint64_t) insn)) { in get_plt()
546 plt = (void *) mod->arch.init_plt->sh_addr; in get_plt()
547 plt_end = (void *) plt + mod->arch.init_plt->sh_size; in get_plt()
549 plt = (void *) mod->arch.core_plt->sh_addr; in get_plt()
550 plt_end = (void *) plt + mod->arch.core_plt->sh_size; in get_plt()
565 if (!patch_plt(mod, plt, target_ip, target_gp)) { in get_plt()
583 get_fdesc (struct module *mod, uint64_t value, int *okp) in get_fdesc() argument
585 struct fdesc *fdesc = (void *) mod->arch.opd->sh_addr; in get_fdesc()
591 printk(KERN_ERR "%s: fdesc for zero requested!\n", mod->name); in get_fdesc()
595 if (!is_internal(mod, value)) in get_fdesc()
606 if ((uint64_t) ++fdesc >= mod->arch.opd->sh_addr + mod->arch.opd->sh_size) in get_fdesc()
612 fdesc->gp = mod->arch.gp; in get_fdesc()
617 do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend, in do_reloc() argument
632 case RV_GPREL: val -= mod->arch.gp; break; in do_reloc()
633 case RV_LTREL: val = get_ltoff(mod, val, &ok); break; in do_reloc()
634 case RV_PLTREL: val = get_plt(mod, location, val, &ok); break; in do_reloc()
635 case RV_FPTR: val = get_fdesc(mod, val, &ok); break; in do_reloc()
637 case RV_LTREL_FPTR: val = get_ltoff(mod, get_fdesc(mod, val, &ok), &ok); break; in do_reloc()
642 if ((in_init(mod, val) && in_core(mod, (uint64_t)location)) || in do_reloc()
643 (in_core(mod, val) && in_init(mod, (uint64_t)location))) { in do_reloc()
650 val = get_fdesc(mod, val, &ok); in do_reloc()
651 val = get_plt(mod, location, val, &ok); in do_reloc()
653 } else if (!is_internal(mod, val)) in do_reloc()
654 val = get_plt(mod, location, val, &ok); in do_reloc()
678 val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core); in do_reloc()
688 if (!is_internal(mod, val)) { in do_reloc()
703 val = get_fdesc(mod, get_plt(mod, location, val, &ok), &ok); in do_reloc()
715 if (gp_addressable(mod, val)) in do_reloc()
716 val -= mod->arch.gp; in do_reloc()
718 val = get_ltoff(mod, val, &ok); in do_reloc()
723 if (gp_addressable(mod, val)) { in do_reloc()
733 mod->name, reloc_name[r_type]); in do_reloc()
736 mod->name, r_type); in do_reloc()
748 mod->name, reloc_name[r_type] ? reloc_name[r_type] : "?"); in do_reloc()
752 printk(KERN_ERR "%s: unknown reloc %x\n", mod->name, r_type); in do_reloc()
763 case RF_INSN21B: ok = apply_imm21b(mod, location, (int64_t) val / 16); break; in do_reloc()
764 case RF_INSN22: ok = apply_imm22(mod, location, val); break; in do_reloc()
765 case RF_INSN64: ok = apply_imm64(mod, location, val); break; in do_reloc()
766 case RF_INSN60: ok = apply_imm60(mod, location, (int64_t) val / 16); break; in do_reloc()
775 mod->name, format, reloc_name[r_type] ? reloc_name[r_type] : "?"); in do_reloc()
780 mod->name, reloc_name[r_type] ? reloc_name[r_type] : "?", format); in do_reloc()
788 unsigned int relsec, struct module *mod) in apply_relocate_add() argument
807 if (!mod->arch.gp) { in apply_relocate_add()
813 if (mod->core_size > MAX_LTOFF) in apply_relocate_add()
818 gp = mod->core_size - MAX_LTOFF / 2; in apply_relocate_add()
820 gp = mod->core_size / 2; in apply_relocate_add()
821 gp = (uint64_t) mod->module_core + ((gp + 7) & -8); in apply_relocate_add()
822 mod->arch.gp = gp; in apply_relocate_add()
827 ret = do_reloc(mod, ELF64_R_TYPE(rela[i].r_info), in apply_relocate_add()
845 register_unwind_table (struct module *mod) in register_unwind_table() argument
847 struct unw_table_entry *start = (void *) mod->arch.unwind->sh_addr; in register_unwind_table()
848 struct unw_table_entry *end = start + mod->arch.unwind->sh_size / sizeof (*start); in register_unwind_table()
854 if (in_init(mod, e1->start_offset)) in register_unwind_table()
875 if (in_init(mod, start->start_offset)) { in register_unwind_table()
884 mod->name, mod->arch.gp, num_init, num_core); in register_unwind_table()
890 mod->arch.core_unw_table = unw_add_unwind_table(mod->name, 0, mod->arch.gp, in register_unwind_table()
893 mod->arch.core_unw_table, core, core + num_core); in register_unwind_table()
896 mod->arch.init_unw_table = unw_add_unwind_table(mod->name, 0, mod->arch.gp, in register_unwind_table()
899 mod->arch.init_unw_table, init, init + num_init); in register_unwind_table()
904 module_finalize (const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs, struct module *mod) in module_finalize() argument
906 DEBUGP("%s: init: entry=%p\n", __func__, mod->init); in module_finalize()
907 if (mod->arch.unwind) in module_finalize()
908 register_unwind_table(mod); in module_finalize()
913 module_arch_cleanup (struct module *mod) in module_arch_cleanup() argument
915 if (mod->arch.init_unw_table) in module_arch_cleanup()
916 unw_remove_unwind_table(mod->arch.init_unw_table); in module_arch_cleanup()
917 if (mod->arch.core_unw_table) in module_arch_cleanup()
918 unw_remove_unwind_table(mod->arch.core_unw_table); in module_arch_cleanup()