Home | History | Annotate | Download | only in src

Lines Matching refs:ehdr

104 static void check_note_section (Ebl *ebl, GElf_Ehdr *ehdr,
353 check_elf_header (Ebl *ebl, GElf_Ehdr *ehdr, size_t size)
359 if (ehdr->e_ident[EI_MAG0] != ELFMAG0)
361 if (ehdr->e_ident[EI_MAG1] != ELFMAG1)
363 if (ehdr->e_ident[EI_MAG2] != ELFMAG2)
365 if (ehdr->e_ident[EI_MAG3] != ELFMAG3)
368 if (ehdr->e_ident[EI_CLASS] != ELFCLASS32
369 && ehdr->e_ident[EI_CLASS] != ELFCLASS64)
371 EI_CLASS, ehdr->e_ident[EI_CLASS]);
373 if (ehdr->e_ident[EI_DATA] != ELFDATA2LSB
374 && ehdr->e_ident[EI_DATA] != ELFDATA2MSB)
376 EI_DATA, ehdr->e_ident[EI_DATA]);
378 if (ehdr->e_ident[EI_VERSION] != EV_CURRENT)
380 EI_VERSION, ehdr->e_ident[EI_VERSION]);
383 if (ehdr->e_ident[EI_OSABI] != ELFOSABI_NONE)
386 ebl_osabi_name (ebl, ehdr->e_ident[EI_OSABI], buf, sizeof (buf)));
389 if (ehdr->e_ident[EI_ABIVERSION] != 0)
391 EI_ABIVERSION, ehdr->e_ident[EI_ABIVERSION]);
394 if (ehdr->e_ident[cnt] != 0)
398 if (ehdr->e_type != ET_REL && ehdr->e_type != ET_EXEC
399 && ehdr->e_type != ET_DYN && ehdr->e_type != ET_CORE)
400 ERROR (gettext ("unknown object file type %d\n"), ehdr->e_type);
404 if (valid_e_machine[cnt] == ehdr->e_machine)
407 ERROR (gettext ("unknown machine type %d\n"), ehdr->e_machine);
410 if (ehdr->e_version != EV_CURRENT)
414 if (ehdr->e_phoff == 0)
416 if (ehdr->e_phnum != 0)
418 else if (ehdr->e_type == ET_EXEC || ehdr->e_type == ET_DYN)
422 else if (ehdr->e_phnum == 0)
426 shnum = ehdr->e_shnum;
427 shstrndx = ehdr->e_shstrndx;
428 if (ehdr->e_shoff == 0)
430 if (ehdr->e_shnum != 0)
432 else if (ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN
433 && ehdr->e_type != ET_CORE)
438 if (ehdr->e_shnum == 0)
455 if (ehdr->e_shstrndx == SHN_XINDEX)
469 if (!ebl_machine_flag_check (ebl, ehdr->e_flags))
471 ebl_machine_flag_name (ebl, ehdr->e_flags, buf, sizeof (buf)));
476 if (ehdr->e_ehsize != 0 && ehdr->e_ehsize != sizeof (Elf32_Ehdr))
477 ERROR (gettext ("invalid ELF header size: %hd\n"), ehdr->e_ehsize);
479 if (ehdr->e_phentsize != 0 && ehdr->e_phentsize != sizeof (Elf32_Phdr))
481 ehdr->e_phentsize);
482 else if (ehdr->e_phoff + ehdr->e_phnum * ehdr->e_phentsize > size)
485 if (ehdr->e_shentsize != 0 && ehdr->e_shentsize != sizeof (Elf32_Shdr))
487 ehdr->e_shentsize);
488 else if (ehdr->e_shoff + ehdr->e_shnum * ehdr->e_shentsize > size)
493 if (ehdr->e_ehsize != 0 && ehdr->e_ehsize != sizeof (Elf64_Ehdr))
494 ERROR (gettext ("invalid ELF header size: %hd\n"), ehdr->e_ehsize);
496 if (ehdr->e_phentsize != 0 && ehdr->e_phentsize != sizeof (Elf64_Phdr))
498 ehdr->e_phentsize);
499 else if (ehdr->e_phoff + ehdr->e_phnum * ehdr->e_phentsize > size)
502 if (ehdr->e_shentsize != 0 && ehdr->e_shentsize != sizeof (Elf64_Shdr))
504 ehdr->e_shentsize);
505 else if (ehdr->e_shoff + ehdr->e_shnum * ehdr->e_shentsize > size)
563 check_symtab (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
718 if (ehdr->e_type != ET_REL)
739 GElf_Addr sh_addr = (ehdr->e_type == ET_REL ? 0
743 if (! ebl_check_special_symbol (ebl, ehdr, sym, name,
779 if (ehdr->e_type == ET_REL)
801 for (pcnt = 0; pcnt < ehdr->e_phnum; ++pcnt)
808 if (pcnt == ehdr->e_phnum)
884 ehdr->e_shstrndx,
905 : elf_strptr (ebl->elf, ehdr->e_shstrndx,
909 if (xndx != SHN_UNDEF || ehdr->e_type != ET_REL)
925 if (!ebl_check_special_symbol (ebl, ehdr, sym, name,
928 if (ehdr->e_type != ET_REL
956 for (int pcnt = 0; pcnt < ehdr->e_phnum; ++pcnt)
986 is_rel_dyn (Ebl *ebl, const GElf_Ehdr *ehdr, int idx, const GElf_Shdr *shdr,
990 if (ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN)
1148 check_reloc_shdr (Ebl *ebl, const GElf_Ehdr *ehdr, const GElf_Shdr *shdr,
1167 reldyn = is_rel_dyn (ebl, ehdr, idx, shdr, true);
1202 for (int i = 0; i < ehdr->e_phnum; ++i)
1269 check_one_reloc (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *relshdr, int idx,
1280 else if (((ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN)
1327 && (r_offset - (ehdr->e_type == ET_REL ? 0
1350 if ((ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN)
1390 check_rela (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
1404 bool reldyn = check_reloc_shdr (ebl, ehdr, shdr, idx, ELF_T_RELA, &destshdr,
1425 check_one_reloc (ebl, ehdr, shdr, idx, cnt, symshdr, symdata,
1440 check_rel (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
1454 bool reldyn = check_reloc_shdr (ebl, ehdr, shdr, idx, ELF_T_REL, &destshdr,
1475 check_one_reloc (ebl, ehdr, shdr, idx, cnt, symshdr, symdata,
1494 check_dynamic (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
1689 for (n = 0; n < ehdr->e_phnum; ++n)
1698 if (unlikely (n >= ehdr->e_phnum))
1798 if (ehdr->e_type != ET_DYN)
1830 check_symtab_shndx (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
1832 if (ehdr->e_type != ET_REL)
2135 check_hash (int tag, Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
2137 if (ehdr->e_type == ET_REL)
2202 compare_hash_gnu_hash (Ebl *ebl, GElf_Ehdr *ehdr, size_t hash_idx,
2246 const int bitmap_factor = ehdr->e_ident[EI_CLASS] == ELFCLASS32 ? 1 : 2;
2356 check_group (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
2358 if (ehdr->e_type != ET_REL)
2766 unknown_dependency_p (Elf *elf, GElf_Ehdr *ehdr, const char *fname)
2772 for (i = 0; i < ehdr->e_phnum; ++i)
2777 if (i == ehdr->e_phnum)
2805 check_verneed (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
2860 if (unknown_dependency_p (ebl->elf, ehdr, libname))
3113 check_attributes (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
3158 if (MY_ELFDATA != ehdr->e_ident[EI_DATA])
3218 if (MY_ELFDATA != ehdr->e_ident[EI_DATA])
3363 check_sections (Ebl *ebl, GElf_Ehdr *ehdr)
3365 if (ehdr->e_shoff == 0)
3398 if (shdr->sh_size != 0 && ehdr->e_shnum != 0)
3402 if (shdr->sh_link != 0 && ehdr->e_shstrndx != SHN_XINDEX)
3407 int *segment_flags = xcalloc (ehdr->e_phnum, sizeof segment_flags[0]);
3445 && ebl_bss_plt_p (ebl, ehdr))
3506 if (ehdr->e_type == ET_REL)
3525 && ehdr->e_type != ET_REL)
3662 if (ehdr->e_type != ET_REL && (shdr->sh_flags & SHF_ALLOC) != 0)
3670 ehdr->e_phnum; ++pcnt)
3731 if (pcnt == ehdr->e_phnum)
3745 if (ehdr->e_type == ET_REL)
3751 check_symtab (ebl, ehdr, shdr, cnt);
3755 check_rela (ebl, ehdr, shdr, cnt);
3759 check_rel (ebl, ehdr, shdr, cnt);
3763 check_dynamic (ebl, ehdr, shdr, cnt);
3767 check_symtab_shndx (ebl, ehdr, shdr, cnt);
3771 check_hash (shdr->sh_type, ebl, ehdr, shdr, cnt);
3776 check_hash (shdr->sh_type, ebl, ehdr, shdr, cnt);
3785 check_group (ebl, ehdr, shdr, cnt);
3789 check_note_section (ebl, ehdr, shdr, cnt);
3802 check_verneed (ebl, ehdr, shdr, cnt);
3810 check_attributes (ebl, ehdr, shdr, cnt);
3823 for (int pcnt = 0; pcnt < ehdr->e_phnum; ++pcnt)
3879 compare_hash_gnu_hash (ebl, ehdr, hash_idx, gnu_hash_idx);
3886 check_note_data (Ebl *ebl, const GElf_Ehdr *ehdr,
3901 if (ehdr->e_type == ET_CORE)
3966 check_note (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Phdr *phdr, int cnt)
3968 if (ehdr->e_type != ET_CORE && ehdr->e_type != ET_REL
3969 && ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN)
3986 notes_size = check_note_data (ebl, ehdr, data, 0, cnt, phdr->p_offset);
3997 check_note_section (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
4010 if (ehdr->e_type != ET_CORE && ehdr->e_type != ET_REL
4011 && ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN)
4016 GElf_Off notes_size = check_note_data (ebl, ehdr, data, idx, 0, 0);
4028 check_program_header (Ebl *ebl, GElf_Ehdr *ehdr)
4030 if (ehdr->e_phoff == 0)
4033 if (ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN
4034 && ehdr->e_type != ET_CORE)
4042 for (int cnt = 0; cnt < ehdr->e_phnum; ++cnt)
4081 check_note (ebl, ehdr, phdr, cnt);
4084 if (ehdr->e_type == ET_EXEC && ! has_interp_segment)
4118 for (inner = 0; inner < ehdr->e_phnum; ++inner)
4143 if (inner >= ehdr->e_phnum)
4152 for (inner = 0; inner < ehdr->e_phnum; ++inner)
4166 if (inner >= ehdr->e_phnum)
4172 if (phdr->p_offset != ehdr->e_phoff)
4211 GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
4223 if (ehdr == NULL)
4235 check_elf_header (ebl, ehdr, size);
4238 check_program_header (ebl, ehdr);
4242 check_sections (ebl, ehdr);