Lines Matching refs:elf
303 static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr) in sech_name() argument
305 return (void *)elf->hdr + in sech_name()
306 elf->sechdrs[elf->secindex_strings].sh_offset + in sech_name()
310 static const char *sec_name(struct elf_info *elf, int secindex) in sec_name() argument
312 return sech_name(elf, &elf->sechdrs[secindex]); in sec_name()
317 static enum export export_from_secname(struct elf_info *elf, unsigned int sec) in export_from_secname() argument
319 const char *secname = sec_name(elf, sec); in export_from_secname()
335 static enum export export_from_sec(struct elf_info *elf, unsigned int sec) in export_from_sec() argument
337 if (sec == elf->export_sec) in export_from_sec()
339 else if (sec == elf->export_unused_sec) in export_from_sec()
341 else if (sec == elf->export_gpl_sec) in export_from_sec()
343 else if (sec == elf->export_unused_gpl_sec) in export_from_sec()
345 else if (sec == elf->export_gpl_future_sec) in export_from_sec()
841 static const char *sym_name(struct elf_info *elf, Elf_Sym *sym) in sym_name() argument
844 return elf->strtab + sym->st_name; in sym_name()
921 static void check_section(const char *modname, struct elf_info *elf, in check_section() argument
924 const char *sec = sech_name(elf, sechdr); in check_section()
1050 void (*handler)(const char *modname, struct elf_info *elf,
1056 static void extable_mismatch_handler(const char *modname, struct elf_info *elf,
1299 static inline int is_valid_name(struct elf_info *elf, Elf_Sym *sym) in is_valid_name() argument
1301 const char *name = elf->strtab + sym->st_name; in is_valid_name()
1315 static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr, in find_elf_symbol() argument
1327 relsym_secindex = get_secindex(elf, relsym); in find_elf_symbol()
1328 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { in find_elf_symbol()
1329 if (get_secindex(elf, sym) != relsym_secindex) in find_elf_symbol()
1333 if (!is_valid_name(elf, sym)) in find_elf_symbol()
1359 static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr, in find_elf_symbol2() argument
1366 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { in find_elf_symbol2()
1371 symsec = sec_name(elf, get_secindex(elf, sym)); in find_elf_symbol2()
1374 if (!is_valid_name(elf, sym)) in find_elf_symbol2()
1599 static void default_mismatch_handler(const char *modname, struct elf_info *elf, in default_mismatch_handler() argument
1609 from = find_elf_symbol2(elf, r->r_offset, fromsec); in default_mismatch_handler()
1610 fromsym = sym_name(elf, from); in default_mismatch_handler()
1615 tosec = sec_name(elf, get_secindex(elf, sym)); in default_mismatch_handler()
1616 to = find_elf_symbol(elf, r->r_addend, sym); in default_mismatch_handler()
1617 tosym = sym_name(elf, to); in default_mismatch_handler()
1629 static int is_executable_section(struct elf_info* elf, unsigned int section_index) in is_executable_section() argument
1631 if (section_index > elf->num_sections) in is_executable_section()
1634 return ((elf->sechdrs[section_index].sh_flags & SHF_EXECINSTR) == SHF_EXECINSTR); in is_executable_section()
1674 static void report_extable_warnings(const char* modname, struct elf_info* elf, in report_extable_warnings() argument
1679 Elf_Sym* fromsym = find_elf_symbol2(elf, r->r_offset, fromsec); in report_extable_warnings()
1680 const char* fromsym_name = sym_name(elf, fromsym); in report_extable_warnings()
1681 Elf_Sym* tosym = find_elf_symbol(elf, r->r_addend, sym); in report_extable_warnings()
1682 const char* tosym_name = sym_name(elf, tosym); in report_extable_warnings()
1700 is_executable_section(elf, get_secindex(elf, sym))) in report_extable_warnings()
1712 static void extable_mismatch_handler(const char* modname, struct elf_info *elf, in extable_mismatch_handler() argument
1717 const char* tosec = sec_name(elf, get_secindex(elf, sym)); in extable_mismatch_handler()
1721 report_extable_warnings(modname, elf, mismatch, r, sym, fromsec, tosec); in extable_mismatch_handler()
1730 else if (!is_executable_section(elf, get_secindex(elf, sym))) { in extable_mismatch_handler()
1748 static void check_section_mismatch(const char *modname, struct elf_info *elf, in check_section_mismatch() argument
1751 const char *tosec = sec_name(elf, get_secindex(elf, sym)); in check_section_mismatch()
1756 mismatch->handler(modname, elf, mismatch, in check_section_mismatch()
1759 default_mismatch_handler(modname, elf, mismatch, in check_section_mismatch()
1764 static unsigned int *reloc_location(struct elf_info *elf, in reloc_location() argument
1767 Elf_Shdr *sechdrs = elf->sechdrs; in reloc_location()
1770 return (void *)elf->hdr + sechdrs[section].sh_offset + in reloc_location()
1774 static int addend_386_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) in addend_386_rel() argument
1777 unsigned int *location = reloc_location(elf, sechdr, r); in addend_386_rel()
1786 if (elf->hdr->e_type == ET_EXEC) in addend_386_rel()
1810 static int addend_arm_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) in addend_arm_rel() argument
1818 (elf->symtab_start + ELF_R_SYM(r->r_info)); in addend_arm_rel()
1827 r->r_addend = (int)(long)(elf->hdr + in addend_arm_rel()
1837 static int addend_mips_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) in addend_mips_rel() argument
1840 unsigned int *location = reloc_location(elf, sechdr, r); in addend_mips_rel()
1860 static void section_rela(const char *modname, struct elf_info *elf, in section_rela() argument
1869 Elf_Rela *start = (void *)elf->hdr + sechdr->sh_offset; in section_rela()
1872 fromsec = sech_name(elf, sechdr); in section_rela()
1881 if (elf->hdr->e_machine == EM_MIPS) { in section_rela()
1896 sym = elf->symtab_start + r_sym; in section_rela()
1902 check_section_mismatch(modname, elf, &r, sym, fromsec); in section_rela()
1906 static void section_rel(const char *modname, struct elf_info *elf, in section_rel() argument
1915 Elf_Rel *start = (void *)elf->hdr + sechdr->sh_offset; in section_rel()
1918 fromsec = sech_name(elf, sechdr); in section_rel()
1927 if (elf->hdr->e_machine == EM_MIPS) { in section_rel()
1942 switch (elf->hdr->e_machine) { in section_rel()
1944 if (addend_386_rel(elf, sechdr, &r)) in section_rel()
1948 if (addend_arm_rel(elf, sechdr, &r)) in section_rel()
1952 if (addend_mips_rel(elf, sechdr, &r)) in section_rel()
1956 sym = elf->symtab_start + r_sym; in section_rel()
1962 check_section_mismatch(modname, elf, &r, sym, fromsec); in section_rel()
1979 struct elf_info *elf) in check_sec_ref() argument
1982 Elf_Shdr *sechdrs = elf->sechdrs; in check_sec_ref()
1985 for (i = 0; i < elf->num_sections; i++) { in check_sec_ref()
1986 check_section(modname, elf, &elf->sechdrs[i]); in check_sec_ref()
1989 section_rela(modname, elf, &elf->sechdrs[i]); in check_sec_ref()
1991 section_rel(modname, elf, &elf->sechdrs[i]); in check_sec_ref()