Lines Matching refs:elf
723 static const char *sym_name(struct elf_info *elf, Elf_Sym *sym) in sym_name() argument
726 return elf->strtab + sym->st_name; in sym_name()
785 static void check_section(const char *modname, struct elf_info *elf, in check_section() argument
788 const char *sec = sech_name(elf, sechdr); in check_section()
894 void (*handler)(const char *modname, struct elf_info *elf,
900 static void extable_mismatch_handler(const char *modname, struct elf_info *elf,
1132 static inline int is_valid_name(struct elf_info *elf, Elf_Sym *sym) in is_valid_name() argument
1134 const char *name = elf->strtab + sym->st_name; in is_valid_name()
1148 static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr, in find_elf_symbol() argument
1160 relsym_secindex = get_secindex(elf, relsym); in find_elf_symbol()
1161 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { in find_elf_symbol()
1162 if (get_secindex(elf, sym) != relsym_secindex) in find_elf_symbol()
1166 if (!is_valid_name(elf, sym)) in find_elf_symbol()
1192 static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr, in find_elf_symbol2() argument
1199 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { in find_elf_symbol2()
1204 symsec = sec_name(elf, get_secindex(elf, sym)); in find_elf_symbol2()
1207 if (!is_valid_name(elf, sym)) in find_elf_symbol2()
1269 static void default_mismatch_handler(const char *modname, struct elf_info *elf, in default_mismatch_handler() argument
1279 from = find_elf_symbol2(elf, r->r_offset, fromsec); in default_mismatch_handler()
1280 fromsym = sym_name(elf, from); in default_mismatch_handler()
1282 tosec = sec_name(elf, get_secindex(elf, sym)); in default_mismatch_handler()
1283 to = find_elf_symbol(elf, r->r_addend, sym); in default_mismatch_handler()
1284 tosym = sym_name(elf, to); in default_mismatch_handler()
1294 static int is_executable_section(struct elf_info* elf, unsigned int section_index) in is_executable_section() argument
1296 if (section_index > elf->num_sections) in is_executable_section()
1299 return ((elf->sechdrs[section_index].sh_flags & SHF_EXECINSTR) == SHF_EXECINSTR); in is_executable_section()
1339 static void report_extable_warnings(const char* modname, struct elf_info* elf, in report_extable_warnings() argument
1344 Elf_Sym* fromsym = find_elf_symbol2(elf, r->r_offset, fromsec); in report_extable_warnings()
1345 const char* fromsym_name = sym_name(elf, fromsym); in report_extable_warnings()
1346 Elf_Sym* tosym = find_elf_symbol(elf, r->r_addend, sym); in report_extable_warnings()
1347 const char* tosym_name = sym_name(elf, tosym); in report_extable_warnings()
1365 is_executable_section(elf, get_secindex(elf, sym))) in report_extable_warnings()
1377 static void extable_mismatch_handler(const char* modname, struct elf_info *elf, in extable_mismatch_handler() argument
1382 const char* tosec = sec_name(elf, get_secindex(elf, sym)); in extable_mismatch_handler()
1386 report_extable_warnings(modname, elf, mismatch, r, sym, fromsec, tosec); in extable_mismatch_handler()
1395 else if (!is_executable_section(elf, get_secindex(elf, sym))) { in extable_mismatch_handler()
1413 static void check_section_mismatch(const char *modname, struct elf_info *elf, in check_section_mismatch() argument
1416 const char *tosec = sec_name(elf, get_secindex(elf, sym)); in check_section_mismatch()
1421 mismatch->handler(modname, elf, mismatch, in check_section_mismatch()
1424 default_mismatch_handler(modname, elf, mismatch, in check_section_mismatch()
1429 static unsigned int *reloc_location(struct elf_info *elf, in reloc_location() argument
1432 return sym_get_data_by_offset(elf, sechdr->sh_info, r->r_offset); in reloc_location()
1435 static int addend_386_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) in addend_386_rel() argument
1438 unsigned int *location = reloc_location(elf, sechdr, r); in addend_386_rel()
1468 static int addend_arm_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) in addend_arm_rel() argument
1476 (elf->symtab_start + ELF_R_SYM(r->r_info)); in addend_arm_rel()
1485 r->r_addend = (int)(long)(elf->hdr + in addend_arm_rel()
1495 static int addend_mips_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) in addend_mips_rel() argument
1498 unsigned int *location = reloc_location(elf, sechdr, r); in addend_mips_rel()
1526 static void section_rela(const char *modname, struct elf_info *elf, in section_rela() argument
1535 Elf_Rela *start = (void *)elf->hdr + sechdr->sh_offset; in section_rela()
1538 fromsec = sec_name(elf, sechdr->sh_info); in section_rela()
1546 if (elf->hdr->e_machine == EM_MIPS) { in section_rela()
1561 switch (elf->hdr->e_machine) { in section_rela()
1568 sym = elf->symtab_start + r_sym; in section_rela()
1574 check_section_mismatch(modname, elf, &r, sym, fromsec); in section_rela()
1578 static void section_rel(const char *modname, struct elf_info *elf, in section_rel() argument
1587 Elf_Rel *start = (void *)elf->hdr + sechdr->sh_offset; in section_rel()
1590 fromsec = sec_name(elf, sechdr->sh_info); in section_rel()
1598 if (elf->hdr->e_machine == EM_MIPS) { in section_rel()
1613 switch (elf->hdr->e_machine) { in section_rel()
1615 if (addend_386_rel(elf, sechdr, &r)) in section_rel()
1619 if (addend_arm_rel(elf, sechdr, &r)) in section_rel()
1623 if (addend_mips_rel(elf, sechdr, &r)) in section_rel()
1627 sym = elf->symtab_start + r_sym; in section_rel()
1633 check_section_mismatch(modname, elf, &r, sym, fromsec); in section_rel()
1649 static void check_sec_ref(const char *modname, struct elf_info *elf) in check_sec_ref() argument
1652 Elf_Shdr *sechdrs = elf->sechdrs; in check_sec_ref()
1655 for (i = 0; i < elf->num_sections; i++) { in check_sec_ref()
1656 check_section(modname, elf, &elf->sechdrs[i]); in check_sec_ref()
1659 section_rela(modname, elf, &elf->sechdrs[i]); in check_sec_ref()
1661 section_rel(modname, elf, &elf->sechdrs[i]); in check_sec_ref()