Home | History | Annotate | Download | only in src

Lines Matching full:ehdr

320 section_name (Ebl *ebl, GElf_Ehdr *ehdr, int idx)
354 check_elf_header (Ebl *ebl, GElf_Ehdr *ehdr, size_t size)
360 if (ehdr->e_ident[EI_MAG0] != ELFMAG0)
362 if (ehdr->e_ident[EI_MAG1] != ELFMAG1)
364 if (ehdr->e_ident[EI_MAG2] != ELFMAG2)
366 if (ehdr->e_ident[EI_MAG3] != ELFMAG3)
369 if (ehdr->e_ident[EI_CLASS] != ELFCLASS32
370 && ehdr->e_ident[EI_CLASS] != ELFCLASS64)
372 EI_CLASS, ehdr->e_ident[EI_CLASS]);
374 if (ehdr->e_ident[EI_DATA] != ELFDATA2LSB
375 && ehdr->e_ident[EI_DATA] != ELFDATA2MSB)
377 EI_DATA, ehdr->e_ident[EI_DATA]);
379 if (ehdr->e_ident[EI_VERSION] != EV_CURRENT)
381 EI_VERSION, ehdr->e_ident[EI_VERSION]);
384 if (ehdr->e_ident[EI_OSABI] != ELFOSABI_NONE)
387 ebl_osabi_name (ebl, ehdr->e_ident[EI_OSABI], buf, sizeof (buf)));
390 if (ehdr->e_ident[EI_ABIVERSION] != 0)
392 EI_ABIVERSION, ehdr->e_ident[EI_ABIVERSION]);
395 if (ehdr->e_ident[cnt] != 0)
399 if (ehdr->e_type != ET_REL && ehdr->e_type != ET_EXEC
400 && ehdr->e_type != ET_DYN && ehdr->e_type != ET_CORE)
401 ERROR (gettext ("unknown object file type %d\n"), ehdr->e_type);
405 if (valid_e_machine[cnt] == ehdr->e_machine)
408 ERROR (gettext ("unknown machine type %d\n"), ehdr->e_machine);
411 if (ehdr->e_version != EV_CURRENT)
415 if (ehdr->e_phoff == 0)
417 if (ehdr->e_phnum != 0)
419 else if (ehdr->e_type == ET_EXEC || ehdr->e_type == ET_DYN)
423 else if (ehdr->e_phnum == 0)
427 shnum = ehdr->e_shnum;
428 shstrndx = ehdr->e_shstrndx;
429 if (ehdr->e_shoff == 0)
431 if (ehdr->e_shnum != 0)
433 else if (ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN
434 && ehdr->e_type != ET_CORE)
439 if (ehdr->e_shnum == 0)
458 if (ehdr->e_shstrndx == SHN_XINDEX)
480 if (!ebl_machine_flag_check (ebl, ehdr->e_flags))
482 ebl_machine_flag_name (ebl, ehdr->e_flags, buf, sizeof (buf)));
487 if (ehdr->e_ehsize != 0 && ehdr->e_ehsize != sizeof (Elf32_Ehdr))
488 ERROR (gettext ("invalid ELF header size: %hd\n"), ehdr->e_ehsize);
490 if (ehdr->e_phentsize != 0 && ehdr->e_phentsize != sizeof (Elf32_Phdr))
492 ehdr->e_phentsize);
493 else if (ehdr->e_phoff + ehdr->e_phnum * ehdr->e_phentsize > size)
496 if (ehdr->e_shentsize != 0 && ehdr->e_shentsize != sizeof (Elf32_Shdr))
498 ehdr->e_shentsize);
499 else if (ehdr->e_shoff + ehdr->e_shnum * ehdr->e_shentsize > size)
504 if (ehdr->e_ehsize != 0 && ehdr->e_ehsize != sizeof (Elf64_Ehdr))
505 ERROR (gettext ("invalid ELF header size: %hd\n"), ehdr->e_ehsize);
507 if (ehdr->e_phentsize != 0 && ehdr->e_phentsize != sizeof (Elf64_Phdr))
509 ehdr->e_phentsize);
510 else if (ehdr->e_phoff + ehdr->e_phnum * ehdr->e_phentsize > size)
513 if (ehdr->e_shentsize != 0 && ehdr->e_shentsize != sizeof (Elf64_Shdr))
515 ehdr->e_shentsize);
516 else if (ehdr->e_shoff + ehdr->e_shnum * ehdr->e_shentsize > size)
525 check_scn_group (Ebl *ebl, GElf_Ehdr *ehdr, int idx)
568 idx, section_name (ebl, ehdr, idx));
572 idx, section_name (ebl, ehdr, idx),
573 cnt, section_name (ebl, ehdr, cnt));
579 check_symtab (Ebl *ebl, GElf_Ehdr *ehdr, int idx)
596 idx, section_name (ebl, ehdr, idx));
602 shdr->sh_link, section_name (ebl, ehdr, shdr->sh_link),
603 idx, section_name (ebl, ehdr, idx));
635 cnt, section_name (ebl, ehdr, cnt));
643 idx, section_name (ebl, ehdr, idx), 0, elf_errmsg (-1));
648 idx, section_name (ebl, ehdr, idx), "st_name");
651 idx, section_name (ebl, ehdr, idx), "st_value");
654 idx, section_name (ebl, ehdr, idx), "st_size");
657 idx, section_name (ebl, ehdr, idx), "st_info");
660 idx, section_name (ebl, ehdr, idx), "st_other");
663 idx, section_name (ebl, ehdr, idx), "st_shndx");
667 xndxscnidx, section_name (ebl, ehdr, xndxscnidx));
676 idx, section_name (ebl, ehdr, idx), cnt, elf_errmsg (-1));
684 idx, section_name (ebl, ehdr, idx), cnt);
697 idx, section_name (ebl, ehdr, idx), cnt);
703 xndxscnidx, section_name (ebl, ehdr, xndxscnidx), cnt,
715 idx, section_name (ebl, ehdr, idx), cnt);
721 idx, section_name (ebl, ehdr, idx), cnt);
726 idx, section_name (ebl, ehdr, idx), cnt);
731 if (ehdr->e_type != ET_REL)
734 idx, section_name (ebl, ehdr, idx), cnt);
738 idx, section_name (ebl, ehdr, idx), cnt);
742 idx, section_name (ebl, ehdr, idx), cnt);
757 idx, section_name (ebl, ehdr, idx), cnt);
762 idx, section_name (ebl, ehdr, idx), cnt,
763 (int) xndx, section_name (ebl, ehdr, xndx));
770 idx, section_name (ebl, ehdr, idx), cnt,
771 (int) xndx, section_name (ebl, ehdr, xndx));
773 if (ehdr->e_type == ET_REL)
780 idx, section_name (ebl, ehdr, idx), cnt,
781 (int) xndx, section_name (ebl, ehdr, xndx));
786 idx, section_name (ebl, ehdr, idx), cnt,
787 (int) xndx, section_name (ebl, ehdr, xndx));
795 for (pcnt = 0; pcnt < ehdr->e_phnum; ++pcnt)
802 if (pcnt == ehdr->e_phnum)
807 idx, section_name (ebl, ehdr, idx), cnt);
815 idx, section_name (ebl, ehdr, idx), cnt,
816 (int) xndx, section_name (ebl, ehdr, xndx));
822 idx, section_name (ebl, ehdr, idx), cnt,
823 (int) xndx, section_name (ebl, ehdr, xndx));
829 idx, section_name (ebl, ehdr, idx), cnt,
830 (int) xndx, section_name (ebl, ehdr, xndx));
842 idx, section_name (ebl, ehdr, idx), cnt);
849 idx, section_name (ebl, ehdr, idx), cnt);
856 idx, section_name (ebl, ehdr, idx), cnt);
873 const char *sname = elf_strptr (ebl->elf, ehdr->e_shstrndx,
885 idx, section_name (ebl, ehdr, idx),
892 idx, section_name (ebl, ehdr, idx),
903 idx, section_name (ebl, ehdr, idx));
912 for (pcnt = 0; pcnt < ehdr->e_phnum; ++pcnt)
922 idx, section_name (ebl, ehdr, idx),
929 idx, section_name (ebl, ehdr, idx),
943 is_rel_dyn (Ebl *ebl, GElf_Ehdr *ehdr, int idx, GElf_Shdr *shdr, bool rela)
946 if (ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN)
950 if (strcmp (section_name (ebl, ehdr, idx), rela ? ".rela.dyn" : ".rel.dyn"))
982 idx, section_name (ebl, ehdr, idx),
996 check_rela (Ebl *ebl, GElf_Ehdr *ehdr, int idx)
1016 idx, section_name (ebl, ehdr, idx));
1023 idx, section_name (ebl, ehdr, idx));
1033 reldyn = is_rel_dyn (ebl, ehdr, idx, shdr, true);
1037 idx, section_name (ebl, ehdr, idx));
1045 idx, section_name (ebl, ehdr, idx));
1052 idx, section_name (ebl, ehdr, idx));
1059 idx, section_name (ebl, ehdr, idx));
1076 idx, section_name (ebl, ehdr, idx), cnt, elf_errmsg (-1));
1082 idx, section_name (ebl, ehdr, idx), cnt);
1086 idx, section_name (ebl, ehdr, idx), cnt);
1094 idx, section_name (ebl, ehdr, idx), cnt);
1109 idx, section_name (ebl, ehdr, idx), cnt,
1124 idx, section_name (ebl, ehdr, idx), cnt);
1131 check_rel (Ebl *ebl, GElf_Ehdr *ehdr, int idx)
1151 idx, section_name (ebl, ehdr, idx));
1158 idx, section_name (ebl, ehdr, idx));
1168 reldyn = is_rel_dyn (ebl, ehdr, idx, shdr, false);
1172 idx, section_name (ebl, ehdr, idx));
1180 idx, section_name (ebl, ehdr, idx));
1187 idx, section_name (ebl, ehdr, idx));
1194 idx, section_name (ebl, ehdr, idx));
1211 idx, section_name (ebl, ehdr, idx), cnt, elf_errmsg (-1));
1217 idx, section_name (ebl, ehdr, idx), cnt);
1221 idx, section_name (ebl, ehdr, idx), cnt);
1229 idx, section_name (ebl, ehdr, idx), cnt);
1244 idx, section_name (ebl, ehdr, idx), cnt,
1260 idx, section_name (ebl, ehdr, idx), cnt);
1271 check_dynamic (Ebl *ebl, GElf_Ehdr *ehdr, int idx)
1338 idx, section_name (ebl, ehdr, idx));
1346 shdr->sh_link, section_name (ebl, ehdr, shdr->sh_link),
1347 idx, section_name (ebl, ehdr, idx));
1352 idx, section_name (ebl, ehdr, idx));
1356 idx, section_name (ebl, ehdr, idx));
1369 idx, section_name (ebl, ehdr, idx), cnt, elf_errmsg (-1));
1377 idx, section_name (ebl, ehdr, idx));
1383 idx, section_name (ebl, ehdr, idx), cnt);
1395 idx, section_name (ebl, ehdr, idx), cnt,
1405 idx, section_name (ebl, ehdr, idx), cnt,
1417 idx, section_name (ebl, ehdr, idx), cnt);
1442 idx, section_name (ebl, ehdr, idx),
1454 idx, section_name (ebl, ehdr, idx),
1464 idx, section_name (ebl, ehdr, idx),
1471 idx, section_name (ebl, ehdr, idx),
1477 check_symtab_shndx (Ebl *ebl, GElf_Ehdr *ehdr, int idx)
1499 idx, section_name (ebl, ehdr, idx));
1507 idx, section_name (ebl, ehdr, idx));
1514 idx, section_name (ebl, ehdr, idx));
1518 idx, section_name (ebl, ehdr, idx));
1531 idx, section_name (ebl, ehdr, idx),
1532 cnt, section_name (ebl, ehdr, cnt));
1566 check_hash (Ebl *ebl, GElf_Ehdr *ehdr, int idx)
1585 idx, section_name (ebl, ehdr, idx));
1593 idx, section_name (ebl, ehdr, idx));
1598 idx, section_name (ebl, ehdr, idx));
1602 idx, section_name (ebl, ehdr, idx));
1608 idx, section_name (ebl, ehdr, idx));
1618 idx, section_name (ebl, ehdr, idx), (long int) shdr->sh_size,
1628 idx, section_name (ebl, ehdr, idx));
1634 idx, section_name (ebl, ehdr, idx), cnt - 2);
1640 idx, section_name (ebl, ehdr, idx), cnt - 2 - nbucket);
1646 check_null (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
1651 idx, section_name (ebl, ehdr, idx), #name)
1666 check_group (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
1668 if (ehdr->e_type != ET_REL)
1672 idx, section_name (ebl, ehdr, idx));
1682 idx, section_name (ebl, ehdr, idx), elf_errmsg (-1));
1688 idx, section_name (ebl, ehdr, idx));
1694 idx, section_name (ebl, ehdr, idx));
1698 idx, section_name (ebl, ehdr, idx));
1703 idx, section_name (ebl, ehdr, idx));
1709 idx, section_name (ebl, ehdr, idx), elf_errmsg (-1));
1719 idx, section_name (ebl, ehdr, idx));
1724 idx, section_name (ebl, ehdr, idx));
1730 idx, section_name (ebl, ehdr, idx));
1734 idx, section_name (ebl, ehdr, idx));
1744 idx, section_name (ebl, ehdr, idx));
1757 idx, section_name (ebl, ehdr, idx), cnt / elsize);
1768 idx, section_name (ebl, ehdr, idx), cnt / elsize,
1775 idx, section_name (ebl, ehdr, idx),
1776 val, section_name (ebl, ehdr, val));
1781 idx, section_name (ebl, ehdr, idx), cnt / elsize,
1782 val, section_name (ebl, ehdr, val));
1788 val, section_name (ebl, ehdr, val));
1898 check_versym (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
1913 idx, section_name (ebl, ehdr, idx),
1914 shdr->sh_link, section_name (ebl, ehdr, shdr->sh_link));
1922 idx, section_name (ebl, ehdr, idx),
1923 shdr->sh_link, section_name (ebl, ehdr, shdr->sh_link));
1933 check_sections (Ebl *ebl, GElf_Ehdr *ehdr)
1940 if (ehdr->e_shoff == 0)
1972 if (shdr->sh_size != 0 && ehdr->e_shnum != 0)
1976 if (shdr->sh_link != 0 && ehdr->e_shstrndx != SHN_XINDEX)
1991 cnt, section_name (ebl, ehdr, cnt), elf_errmsg (-1));
2061 if (ehdr->e_type == ET_REL)
2080 && ehdr->e_type != ET_REL)
2118 cnt, section_name (ebl, ehdr, cnt));
2136 cnt, section_name (ebl, ehdr, cnt),
2144 cnt, section_name (ebl, ehdr, cnt));
2152 cnt, section_name (ebl, ehdr, cnt));
2157 cnt, section_name (ebl, ehdr, cnt));
2164 cnt, section_name (ebl, ehdr, cnt));
2169 cnt, section_name (ebl, ehdr, cnt));
2172 check_scn_group (ebl, ehdr, cnt);
2174 if (ehdr->e_type != ET_REL && (shdr->sh_flags & SHF_ALLOC) != 0)
2182 for (pcnt = 0; pcnt < ehdr->e_phnum; ++pcnt)
2196 cnt, section_name (ebl, ehdr, cnt), pcnt);
2203 cnt, section_name (ebl, ehdr, cnt), pcnt);
2210 cnt, section_name (ebl, ehdr, cnt), pcnt);
2216 if (pcnt == ehdr->e_phnum)
2219 cnt, section_name (ebl, ehdr, cnt));
2225 cnt, section_name (ebl, ehdr, cnt));
2231 check_symtab (ebl, ehdr, cnt);
2235 check_rela (ebl, ehdr, cnt);
2239 check_rel (ebl, ehdr, cnt);
2243 check_dynamic (ebl, ehdr, cnt);
2247 check_symtab_shndx (ebl, ehdr, cnt);
2251 check_hash (ebl, ehdr, cnt);
2255 check_null (ebl, ehdr, shdr, cnt);
2259 check_group (ebl, ehdr, shdr, cnt);
2263 check_versym (ebl, ehdr, shdr, cnt);
2280 check_note (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Phdr *phdr, int cnt)
2282 if (ehdr->e_type != ET_CORE && ehdr->e_type != ET_REL
2283 && ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN)
2311 && ehdr->e_ident[EI_DATA] == ELFDATA2MSB)
2313 && ehdr->e_ident[EI_DATA] == ELFDATA2LSB))
2334 && ehdr->e_ident[EI_DATA] == ELFDATA2MSB)
2336 && ehdr->e_ident[EI_DATA] == ELFDATA2LSB))
2363 if (ehdr->e_ident[EI_CLASS] == ELFCLASS64
2376 if (ehdr->e_type == ET_CORE)
2422 check_program_header (Ebl *ebl, GElf_Ehdr *ehdr)
2424 if (ehdr->e_phoff == 0)
2427 if (ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN
2428 && ehdr->e_type != ET_CORE)
2436 for (int cnt = 0; cnt < ehdr->e_phnum; ++cnt)
2473 check_note (ebl, ehdr, phdr, cnt);
2475 && ehdr->e_type == ET_EXEC && ! has_interp_segment)
2486 for (inner = 0; inner < ehdr->e_phnum; ++inner)
2510 if (inner >= ehdr->e_phnum)
2543 GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
2555 if (ehdr == NULL)
2567 check_elf_header (ebl, ehdr, size);
2570 check_program_header (ebl, ehdr);
2574 check_sections (ebl, ehdr);