Lines Matching refs:ehdr
94 static void check_note_section (Ebl *ebl, GElf_Ehdr *ehdr,
339 check_elf_header (Ebl *ebl, GElf_Ehdr *ehdr, size_t size)
345 if (ehdr->e_ident[EI_MAG0] != ELFMAG0)
347 if (ehdr->e_ident[EI_MAG1] != ELFMAG1)
349 if (ehdr->e_ident[EI_MAG2] != ELFMAG2)
351 if (ehdr->e_ident[EI_MAG3] != ELFMAG3)
354 if (ehdr->e_ident[EI_CLASS] != ELFCLASS32
355 && ehdr->e_ident[EI_CLASS] != ELFCLASS64)
357 EI_CLASS, ehdr->e_ident[EI_CLASS]);
359 if (ehdr->e_ident[EI_DATA] != ELFDATA2LSB
360 && ehdr->e_ident[EI_DATA] != ELFDATA2MSB)
362 EI_DATA, ehdr->e_ident[EI_DATA]);
364 if (ehdr->e_ident[EI_VERSION] != EV_CURRENT)
366 EI_VERSION, ehdr->e_ident[EI_VERSION]);
370 if (ehdr->e_ident[EI_OSABI] != ELFOSABI_NONE
371 && ehdr->e_ident[EI_OSABI] != ELFOSABI_LINUX
372 && ehdr->e_ident[EI_OSABI] != ELFOSABI_FREEBSD)
375 ebl_osabi_name (ebl, ehdr->e_ident[EI_OSABI], buf, sizeof (buf)));
378 if (ehdr->e_ident[EI_ABIVERSION] != 0)
380 EI_ABIVERSION, ehdr->e_ident[EI_ABIVERSION]);
383 if (ehdr->e_ident[cnt] != 0)
387 if (ehdr->e_type != ET_REL && ehdr->e_type != ET_EXEC
388 && ehdr->e_type != ET_DYN && ehdr->e_type != ET_CORE)
389 ERROR (_("unknown object file type %d\n"), ehdr->e_type);
393 if (valid_e_machine[cnt] == ehdr->e_machine)
396 ERROR (_("unknown machine type %d\n"), ehdr->e_machine);
399 if (ehdr->e_version != EV_CURRENT)
403 if (ehdr->e_phoff == 0)
405 if (ehdr->e_phnum != 0)
407 else if (ehdr->e_type == ET_EXEC || ehdr->e_type == ET_DYN)
411 else if (ehdr->e_phnum == 0)
415 shnum = ehdr->e_shnum;
416 shstrndx = ehdr->e_shstrndx;
417 if (ehdr->e_shoff == 0)
419 if (ehdr->e_shnum != 0)
421 else if (ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN
422 && ehdr->e_type != ET_CORE)
427 if (ehdr->e_shnum == 0)
444 if (ehdr->e_shstrndx == SHN_XINDEX)
475 phnum = ehdr->e_phnum;
476 if (ehdr->e_phnum == PN_XNUM)
507 if (!ebl_machine_flag_check (ebl, ehdr->e_flags))
509 ebl_machine_flag_name (ebl, ehdr->e_flags, buf, sizeof (buf)));
514 if (ehdr->e_ehsize != 0 && ehdr->e_ehsize != sizeof (Elf32_Ehdr))
515 ERROR (_("invalid ELF header size: %hd\n"), ehdr->e_ehsize);
517 if (ehdr->e_phentsize != 0 && ehdr->e_phentsize != sizeof (Elf32_Phdr))
519 ehdr->e_phentsize);
520 else if (ehdr->e_phoff + phnum * ehdr->e_phentsize > size)
523 if (ehdr->e_shentsize != 0 && ehdr->e_shentsize != sizeof (Elf32_Shdr))
525 ehdr->e_shentsize);
526 else if (ehdr->e_shoff + shnum * ehdr->e_shentsize > size)
531 if (ehdr->e_ehsize != 0 && ehdr->e_ehsize != sizeof (Elf64_Ehdr))
532 ERROR (_("invalid ELF header size: %hd\n"), ehdr->e_ehsize);
534 if (ehdr->e_phentsize != 0 && ehdr->e_phentsize != sizeof (Elf64_Phdr))
536 ehdr->e_phentsize);
537 else if (ehdr->e_phoff + phnum * ehdr->e_phentsize > size)
540 if (ehdr->e_shentsize != 0 && ehdr->e_shentsize != sizeof (Elf64_Shdr))
542 ehdr->e_shentsize);
543 else if (ehdr->e_shoff + shnum * ehdr->e_shentsize > size)
602 check_symtab (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
771 if (ehdr->e_type != ET_REL)
792 GElf_Addr sh_addr = (ehdr->e_type == ET_REL ? 0
851 if (ehdr->e_type == ET_REL)
987 if (xndx != SHN_UNDEF || ehdr->e_type != ET_REL)
1006 if (ehdr->e_type != ET_REL
1075 is_rel_dyn (Ebl *ebl, const GElf_Ehdr *ehdr, int idx, const GElf_Shdr *shdr,
1079 if (ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN)
1249 check_reloc_shdr (Ebl *ebl, const GElf_Ehdr *ehdr, const GElf_Shdr *shdr,
1267 reldyn = is_rel_dyn (ebl, ehdr, idx, shdr, true);
1371 check_one_reloc (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *relshdr, int idx,
1382 else if (((ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN)
1429 && (r_offset - (ehdr->e_type == ET_REL ? 0
1452 if ((ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN)
1492 check_rela (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
1506 bool reldyn = check_reloc_shdr (ebl, ehdr, shdr, idx, ELF_T_RELA, &destshdr,
1528 check_one_reloc (ebl, ehdr, shdr, idx, cnt, symshdr, symdata,
1543 check_rel (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
1557 bool reldyn = check_reloc_shdr (ebl, ehdr, shdr, idx, ELF_T_REL, &destshdr,
1579 check_one_reloc (ebl, ehdr, shdr, idx, cnt, symshdr, symdata,
1598 check_dynamic (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
1897 if (ehdr->e_type != ET_DYN)
1929 check_symtab_shndx (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
1931 if (ehdr->e_type != ET_REL)
2303 check_hash (int tag, Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
2305 if (ehdr->e_type == ET_REL)
2376 compare_hash_gnu_hash (Ebl *ebl, GElf_Ehdr *ehdr, size_t hash_idx,
2436 const int bitmap_factor = ehdr->e_ident[EI_CLASS] == ELFCLASS32 ? 1 : 2;
2621 check_group (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
2623 if (ehdr->e_type != ET_REL)
3443 check_attributes (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
3478 if (MY_ELFDATA != ehdr->e_ident[EI_DATA])
3538 if (MY_ELFDATA != ehdr->e_ident[EI_DATA])
3700 check_sections (Ebl *ebl, GElf_Ehdr *ehdr)
3702 if (ehdr->e_shoff == 0)
3733 if (shdr->sh_size != 0 && ehdr->e_shnum != 0)
3737 if (shdr->sh_link != 0 && ehdr->e_shstrndx != SHN_XINDEX)
3741 if (shdr->sh_info != 0 && ehdr->e_phnum != PN_XNUM)
3847 if (ehdr->e_type == ET_REL)
3866 && ehdr->e_type != ET_REL)
4048 if (ehdr->e_type != ET_REL && (shdr->sh_flags & SHF_ALLOC) != 0
4164 if (ehdr->e_type == ET_REL)
4170 check_symtab (ebl, ehdr, shdr, cnt);
4174 check_rela (ebl, ehdr, shdr, cnt);
4178 check_rel (ebl, ehdr, shdr, cnt);
4182 check_dynamic (ebl, ehdr, shdr, cnt);
4186 check_symtab_shndx (ebl, ehdr, shdr, cnt);
4190 check_hash (shdr->sh_type, ebl, ehdr, shdr, cnt);
4195 check_hash (shdr->sh_type, ebl, ehdr, shdr, cnt);
4204 check_group (ebl, ehdr, shdr, cnt);
4208 check_note_section (ebl, ehdr, shdr, cnt);
4229 check_attributes (ebl, ehdr, shdr, cnt);
4298 compare_hash_gnu_hash (ebl, ehdr, hash_idx, gnu_hash_idx);
4305 check_note_data (Ebl *ebl, const GElf_Ehdr *ehdr,
4320 if (ehdr->e_type == ET_CORE)
4423 check_note (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Phdr *phdr, int cnt)
4425 if (ehdr->e_type != ET_CORE && ehdr->e_type != ET_REL
4426 && ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN)
4444 notes_size = check_note_data (ebl, ehdr, data, 0, cnt, phdr->p_offset);
4456 check_note_section (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
4469 if (ehdr->e_type != ET_CORE && ehdr->e_type != ET_REL
4470 && ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN)
4475 GElf_Off notes_size = check_note_data (ebl, ehdr, data, idx, 0, 0);
4492 check_program_header (Ebl *ebl, GElf_Ehdr *ehdr)
4494 if (ehdr->e_phoff == 0)
4497 if (ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN
4498 && ehdr->e_type != ET_CORE)
4546 check_note (ebl, ehdr, phdr, cnt);
4549 if (ehdr->e_type == ET_EXEC && ! has_interp_segment)
4653 if (phdr->p_offset != ehdr->e_phoff)
4735 && !(ehdr->e_machine == EM_RISCV
4756 GElf_Ehdr *ehdr __attribute__ ((unused)))
4758 if ((ehdr->e_type == ET_EXEC || ehdr->e_type == ET_DYN)
4780 GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
4792 if (ehdr == NULL)
4811 check_elf_header (ebl, ehdr, size);
4814 check_program_header (ebl, ehdr);
4818 check_sections (ebl, ehdr);
4823 check_exception_data (ebl, ehdr);