Lines Matching full:elf
15 #include <elf.h>
348 static enum export export_from_secname(struct elf_info *elf, unsigned int sec) in export_from_secname() argument
350 const char *secname = sec_name(elf, sec); in export_from_secname()
366 static enum export export_from_sec(struct elf_info *elf, unsigned int sec) in export_from_sec() argument
368 if (sec == elf->export_sec) in export_from_sec()
370 else if (sec == elf->export_unused_sec) in export_from_sec()
372 else if (sec == elf->export_gpl_sec) in export_from_sec()
374 else if (sec == elf->export_unused_gpl_sec) in export_from_sec()
376 else if (sec == elf->export_gpl_future_sec) in export_from_sec()
438 * such as __*_veneer in ARM ELF. in sym_set_crc()
498 /* Is this a valid ELF file? */ in parse_elf()
503 /* Not an ELF file - silently ignore it */ in parse_elf()
506 /* Fix endianness in ELF header */ in parse_elf()
688 /* symbol points to the CRC in the ELF object */ in handle_modversion()
821 static const char *sym_name(struct elf_info *elf, Elf_Sym *sym) in sym_name() argument
824 return elf->strtab + sym->st_name; in sym_name()
901 static void check_section(const char *modname, struct elf_info *elf, in check_section() argument
904 const char *sec = sech_name(elf, sechdr); in check_section()
1030 void (*handler)(const char *modname, struct elf_info *elf,
1036 static void extable_mismatch_handler(const char *modname, struct elf_info *elf,
1212 * Hide section mismatch warnings for ELF local symbols. The goal
1214 * compiler-generated ELF local symbol names such as ".LANCHOR1".
1217 * names to work. (One situation where gcc can autogenerate ELF
1280 static inline int is_valid_name(struct elf_info *elf, Elf_Sym *sym) in is_valid_name() argument
1282 const char *name = elf->strtab + sym->st_name; in is_valid_name()
1296 static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr, in find_elf_symbol() argument
1312 relsym_secindex = get_secindex(elf, relsym); in find_elf_symbol()
1313 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { in find_elf_symbol()
1314 if (get_secindex(elf, sym) != relsym_secindex) in find_elf_symbol()
1318 if (!is_valid_name(elf, sym)) in find_elf_symbol()
1341 * The ELF format may have a better way to detect what type of symbol
1344 static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr, in find_elf_symbol2() argument
1351 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { in find_elf_symbol2()
1356 symsec = sec_name(elf, get_secindex(elf, sym)); in find_elf_symbol2()
1359 if (!is_valid_name(elf, sym)) in find_elf_symbol2()
1584 static void default_mismatch_handler(const char *modname, struct elf_info *elf, in default_mismatch_handler() argument
1594 from = find_elf_symbol2(elf, r->r_offset, fromsec); in default_mismatch_handler()
1595 fromsym = sym_name(elf, from); in default_mismatch_handler()
1600 tosec = sec_name(elf, get_secindex(elf, sym)); in default_mismatch_handler()
1601 to = find_elf_symbol(elf, r->r_addend, sym); in default_mismatch_handler()
1602 tosym = sym_name(elf, to); in default_mismatch_handler()
1614 static int is_executable_section(struct elf_info* elf, unsigned int section_index) in is_executable_section() argument
1616 if (section_index >= elf->num_sections) in is_executable_section()
1617 fatal("section_index is outside elf->num_sections!\n"); in is_executable_section()
1619 return ((elf->sechdrs[section_index].sh_flags & SHF_EXECINSTR) == SHF_EXECINSTR); in is_executable_section()
1659 static void report_extable_warnings(const char* modname, struct elf_info* elf, in report_extable_warnings() argument
1664 Elf_Sym* fromsym = find_elf_symbol2(elf, r->r_offset, fromsec); in report_extable_warnings()
1665 const char* fromsym_name = sym_name(elf, fromsym); in report_extable_warnings()
1666 Elf_Sym* tosym = find_elf_symbol(elf, r->r_addend, sym); in report_extable_warnings()
1667 const char* tosym_name = sym_name(elf, tosym); in report_extable_warnings()
1685 is_executable_section(elf, get_secindex(elf, sym))) in report_extable_warnings()
1697 static void extable_mismatch_handler(const char* modname, struct elf_info *elf, in extable_mismatch_handler() argument
1702 const char* tosec = sec_name(elf, get_secindex(elf, sym)); in extable_mismatch_handler()
1706 report_extable_warnings(modname, elf, mismatch, r, sym, fromsec, tosec); in extable_mismatch_handler()
1715 else if (!is_executable_section(elf, get_secindex(elf, sym))) { in extable_mismatch_handler()
1733 static void check_section_mismatch(const char *modname, struct elf_info *elf, in check_section_mismatch() argument
1736 const char *tosec = sec_name(elf, get_secindex(elf, sym)); in check_section_mismatch()
1741 mismatch->handler(modname, elf, mismatch, in check_section_mismatch()
1744 default_mismatch_handler(modname, elf, mismatch, in check_section_mismatch()
1749 static unsigned int *reloc_location(struct elf_info *elf, in reloc_location() argument
1752 return sym_get_data_by_offset(elf, sechdr->sh_info, r->r_offset); in reloc_location()
1755 static int addend_386_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) in addend_386_rel() argument
1758 unsigned int *location = reloc_location(elf, sechdr, r); in addend_386_rel()
1767 if (elf->hdr->e_type == ET_EXEC) in addend_386_rel()
1798 static int addend_arm_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) in addend_arm_rel() argument
1801 Elf_Sym *sym = elf->symtab_start + ELF_R_SYM(r->r_info); in addend_arm_rel()
1802 void *loc = reloc_location(elf, sechdr, r); in addend_arm_rel()
1822 r->r_addend = (int)(long)(elf->hdr + in addend_arm_rel()
1832 static int addend_mips_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) in addend_mips_rel() argument
1835 unsigned int *location = reloc_location(elf, sechdr, r); in addend_mips_rel()
1863 static void section_rela(const char *modname, struct elf_info *elf, in section_rela() argument
1872 Elf_Rela *start = (void *)elf->hdr + sechdr->sh_offset; in section_rela()
1875 fromsec = sech_name(elf, sechdr); in section_rela()
1884 if (elf->hdr->e_machine == EM_MIPS) { in section_rela()
1899 switch (elf->hdr->e_machine) { in section_rela()
1906 sym = elf->symtab_start + r_sym; in section_rela()
1912 check_section_mismatch(modname, elf, &r, sym, fromsec); in section_rela()
1916 static void section_rel(const char *modname, struct elf_info *elf, in section_rel() argument
1925 Elf_Rel *start = (void *)elf->hdr + sechdr->sh_offset; in section_rel()
1928 fromsec = sech_name(elf, sechdr); in section_rel()
1937 if (elf->hdr->e_machine == EM_MIPS) { in section_rel()
1952 switch (elf->hdr->e_machine) { in section_rel()
1954 if (addend_386_rel(elf, sechdr, &r)) in section_rel()
1958 if (addend_arm_rel(elf, sechdr, &r)) in section_rel()
1962 if (addend_mips_rel(elf, sechdr, &r)) in section_rel()
1966 sym = elf->symtab_start + r_sym; in section_rel()
1972 check_section_mismatch(modname, elf, &r, sym, fromsec); in section_rel()
1989 struct elf_info *elf) in check_sec_ref() argument
1992 Elf_Shdr *sechdrs = elf->sechdrs; in check_sec_ref()
1995 for (i = 0; i < elf->num_sections; i++) { in check_sec_ref()
1996 check_section(modname, elf, &elf->sechdrs[i]); in check_sec_ref()
1999 section_rela(modname, elf, &elf->sechdrs[i]); in check_sec_ref()
2001 section_rel(modname, elf, &elf->sechdrs[i]); in check_sec_ref()