Lines Matching refs:shdr
105 GElf_Shdr *shdr, int idx);
322 GElf_Shdr *shdr;
324 shdr = gelf_getshdr (elf_getscn (ebl->elf, idx), &shdr_mem);
326 return elf_strptr (ebl->elf, shstrndx, shdr->sh_name);
443 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (ebl->elf, 0), &shdr_mem);
444 if (shdr != NULL)
447 if (shdr->sh_size == 0)
451 shnum = shdr->sh_size;
460 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (ebl->elf, 0), &shdr_mem);
461 if (shdr != NULL && shdr->sh_link < shnum)
462 shstrndx = shdr->sh_link;
526 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
527 if (shdr == NULL)
533 if (shdr->sh_type != SHT_GROUP)
563 check_symtab (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
576 GElf_Shdr *strshdr = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
584 shdr->sh_link, section_name (ebl, shdr->sh_link),
616 if (shdr->sh_entsize != gelf_fsize (ebl->elf, ELF_T_SYM, 1, EV_CURRENT))
654 for (size_t cnt = 1; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
673 name = elf_strptr (ebl->elf, shdr->sh_link, sym->st_name);
722 if (cnt < shdr->sh_info)
845 if (cnt >= shdr->sh_info)
852 if (cnt < shdr->sh_info)
986 is_rel_dyn (Ebl *ebl, const GElf_Ehdr *ehdr, int idx, const GElf_Shdr *shdr,
1030 if (dyn->d_un.d_val > shdr->sh_size / shdr->sh_entsize)
1042 inner < shdr->sh_size / shdr->sh_entsize;
1082 if (dyn->d_un.d_val > shdr->sh_size / shdr->sh_entsize)
1094 inner < shdr->sh_size / shdr->sh_entsize;
1148 check_reloc_shdr (Ebl *ebl, const GElf_Ehdr *ehdr, const GElf_Shdr *shdr,
1155 if (shdr->sh_info >= shnum)
1158 else if (shdr->sh_info != 0)
1160 *destshdrp = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_info),
1167 reldyn = is_rel_dyn (ebl, ehdr, idx, shdr, true);
1176 if (shdr->sh_info != 0)
1190 if (shdr->sh_entsize != gelf_fsize (ebl->elf, reltype, 1, EV_CURRENT))
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,
1407 Elf_Scn *symscn = elf_getscn (ebl->elf, shdr->sh_link);
1413 for (size_t cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
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,
1457 Elf_Scn *symscn = elf_getscn (ebl->elf, shdr->sh_link);
1463 for (size_t cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
1475 check_one_reloc (ebl, ehdr, shdr, idx, cnt, symshdr, symdata,
1494 check_dynamic (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
1559 strshdr = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), &strshdr_mem);
1563 shdr->sh_link, section_name (ebl, shdr->sh_link),
1566 if (shdr->sh_entsize != gelf_fsize (ebl->elf, ELF_T_DYN, 1, EV_CURRENT))
1571 if (shdr->sh_info != 0)
1576 for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
1661 shdr->sh_link, section_name (ebl, shdr->sh_link));
1721 shdr->sh_link, section_name (ebl, shdr->sh_link));
1830 check_symtab_shndx (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
1840 Elf_Scn *symscn = elf_getscn (ebl->elf, shdr->sh_link);
1851 if (shdr->sh_entsize != sizeof (Elf32_Word))
1857 && (shdr->sh_size / shdr->sh_entsize
1863 if (shdr->sh_info != 0)
1872 && rshdr->sh_link == shdr->sh_link)
1911 check_sysv_hash (Ebl *ebl, GElf_Shdr *shdr, Elf_Data *data, int idx,
1917 if (shdr->sh_size < (2 + nbucket + nchain) * shdr->sh_entsize)
1920 idx, section_name (ebl, idx), (long int) shdr->sh_size,
1921 (long int) ((2 + nbucket + nchain) * shdr->sh_entsize));
1952 check_sysv_hash64 (Ebl *ebl, GElf_Shdr *shdr, Elf_Data *data, int idx,
1958 if (shdr->sh_size < (2 + nbucket + nchain) * shdr->sh_entsize)
1961 idx, section_name (ebl, idx), (long int) shdr->sh_size,
1962 (long int) ((2 + nbucket + nchain) * shdr->sh_entsize));
1993 check_gnu_hash (Ebl *ebl, GElf_Shdr *shdr, Elf_Data *data, int idx,
2010 if (shdr->sh_size < (4 + bitmask_words + nbuckets) * sizeof (Elf32_Word))
2014 idx, section_name (ebl, idx), (long int) shdr->sh_size,
2024 size_t maxidx = shdr->sh_size / sizeof (Elf32_Word) - (4 + bitmask_words
2031 Elf_Data *symdata = elf_getdata (elf_getscn (ebl->elf, shdr->sh_link), NULL);
2135 check_hash (int tag, Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
2154 GElf_Shdr *symshdr = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
2161 if (shdr->sh_entsize != (tag == SHT_GNU_HASH
2169 if ((shdr->sh_flags & SHF_ALLOC) == 0)
2173 if (shdr->sh_size < (tag == SHT_GNU_HASH ? 4 : 2) * (shdr->sh_entsize ?: 4))
2185 check_sysv_hash64 (ebl, shdr, data, idx, symshdr);
2187 check_sysv_hash (ebl, shdr, data, idx, symshdr);
2191 check_gnu_hash (ebl, shdr, data, idx, symshdr);
2336 check_null (Ebl *ebl, GElf_Shdr *shdr, int idx)
2339 if (extra && shdr->sh_##name != 0) \
2356 check_group (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
2367 Elf_Scn *symscn = elf_getscn (ebl->elf, shdr->sh_link);
2380 if (shdr->sh_info >= symshdr->sh_size / gelf_fsize (ebl->elf, ELF_T_SYM,
2386 if (shdr->sh_flags != 0)
2391 GElf_Sym *sym = gelf_getsym (elf_getdata (symscn, NULL), shdr->sh_info,
2404 && shdr->sh_entsize != elf32_fsize (ELF_T_WORD, 1, EV_CURRENT))
2556 GElf_Shdr *shdr = NULL;
2559 shdr = gelf_getshdr (scn, &shdr_mem);
2560 if (shdr != NULL
2561 && (shdr->sh_type == SHT_REL || shdr->sh_type == SHT_RELA)
2562 && shdr->sh_link == symscnndx)
2574 if (shdr->sh_type == SHT_REL)
2575 for (int i = 0; (size_t) i < shdr->sh_size / shdr->sh_entsize; ++i)
2587 for (int i = 0; (size_t) i < shdr->sh_size / shdr->sh_entsize; ++i)
2607 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (ebl->elf, shndx), &shdr_mem);
2608 return shdr != NULL && shdr->sh_type == SHT_NOBITS;
2654 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
2655 if (shdr == NULL)
2667 Elf_Scn *symscn = elf_getscn (ebl->elf, shdr->sh_link);
2679 shdr->sh_link, section_name (ebl, shdr->sh_link));
2685 if (shdr->sh_size / shdr->sh_entsize
2690 shdr->sh_link, section_name (ebl, shdr->sh_link));
2697 for (int cnt = 1; (size_t) cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
2754 if (!has_copy_reloc (ebl, shdr->sh_link, cnt)
2782 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
2784 if (shdr != NULL && shdr->sh_type == SHT_DYNAMIC && data != NULL)
2785 for (size_t j = 0; j < shdr->sh_size / shdr->sh_entsize; ++j)
2791 const char *str = elf_strptr (elf, shdr->sh_link, dyn->d_un.d_val);
2805 check_verneed (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
2811 GElf_Shdr *strshdr = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
2828 for (int cnt = shdr->sh_info; --cnt >= 0; )
2849 const char *libname = elf_strptr (ebl->elf, shdr->sh_link,
2877 const char *verstr = elf_strptr (ebl->elf, shdr->sh_link,
2934 check_verdef (Ebl *ebl, GElf_Shdr *shdr, int idx)
2940 GElf_Shdr *strshdr = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
2971 for (int cnt = shdr->sh_info; --cnt >= 0; )
3013 const char *name = elf_strptr (ebl->elf, shdr->sh_link, aux->vda_name);
3049 name = elf_strptr (ebl->elf, shdr->sh_link, aux->vda_name);
3113 check_attributes (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
3115 if (shdr->sh_size == 0)
3376 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (ebl->elf, 0), &shdr_mem);
3377 if (shdr == NULL)
3381 if (shdr->sh_name != 0)
3383 if (shdr->sh_type != 0)
3385 if (shdr->sh_flags != 0)
3387 if (shdr->sh_addr != 0)
3389 if (shdr->sh_offset != 0)
3391 if (shdr->sh_info != 0)
3393 if (shdr->sh_addralign != 0)
3395 if (shdr->sh_entsize != 0)
3398 if (shdr->sh_size != 0 && ehdr->e_shnum != 0)
3402 if (shdr->sh_link != 0 && ehdr->e_shstrndx != SHN_XINDEX)
3417 shdr = gelf_getshdr (elf_getscn (ebl->elf, cnt), &shdr_mem);
3418 if (shdr == NULL)
3426 const char *scnname = elf_strptr (ebl->elf, shstrndx, shdr->sh_name);
3450 if (shdr->sh_type != good_type
3451 && (shdr->sh_type != SHT_NOBITS
3461 ebl_section_type_name (ebl, shdr->sh_type,
3469 if ((shdr->sh_flags & ~(SHF_LINK_ORDER | SHF_GROUP))
3477 section_flags_string (shdr->sh_flags
3483 if ((shdr->sh_flags & special_sections[s].attr)
3485 || ((shdr->sh_flags & ~(SHF_LINK_ORDER | SHF_GROUP
3496 section_flags_string (shdr->sh_flags
3511 if ((shdr->sh_flags & SHF_ALLOC) != 0
3516 else if ((shdr->sh_flags & SHF_ALLOC) == 0
3543 if ((shdr->sh_flags & SHF_ALLOC) != 0
3548 else if ((shdr->sh_flags & SHF_ALLOC) == 0
3560 if (shdr->sh_entsize != 0 && shdr->sh_size % shdr->sh_entsize)
3565 if (elf_strptr (ebl->elf, shstrndx, shdr->sh_name) == NULL)
3568 if (shdr->sh_type >= SHT_NUM
3569 && shdr->sh_type != SHT_GNU_ATTRIBUTES
3570 && shdr->sh_type != SHT_GNU_LIBLIST
3571 && shdr->sh_type != SHT_CHECKSUM
3572 && shdr->sh_type != SHT_GNU_verdef
3573 && shdr->sh_type != SHT_GNU_verneed
3574 && shdr->sh_type != SHT_GNU_versym
3575 && ebl_section_type_name (ebl, shdr->sh_type, NULL, 0) == NULL)
3578 (int) shdr->sh_type);
3583 if (shdr->sh_flags & ~(GElf_Xword) ALL_SH_FLAGS)
3585 GElf_Xword sh_flags = shdr->sh_flags & ~(GElf_Xword) ALL_SH_FLAGS;
3601 if (shdr->sh_flags & SHF_TLS)
3604 if (shdr->sh_addr != 0 && !gnuld)
3612 if (shdr->sh_link >= shnum)
3617 if (SH_INFO_LINK_P (shdr) && shdr->sh_info >= shnum)
3622 if ((shdr->sh_flags & SHF_MERGE) == 0
3623 && (shdr->sh_flags & SHF_STRINGS) != 0
3629 if ((shdr->sh_flags & SHF_MERGE) != 0 && shdr->sh_entsize == 0)
3634 if (shdr->sh_flags & SHF_GROUP)
3637 if (shdr->sh_flags & SHF_EXECINSTR)
3639 switch (shdr->sh_type)
3650 cnt, section_name (ebl, cnt), shdr->sh_type);
3654 if ((shdr->sh_flags & SHF_WRITE)
3655 && !ebl_check_special_section (ebl, cnt, shdr,
3662 if (ehdr->e_type != ET_REL && (shdr->sh_flags & SHF_ALLOC) != 0)
3673 && (shdr->sh_flags & SHF_TLS) == 0)
3675 && (shdr->sh_flags & SHF_TLS) != 0))
3676 && phdr->p_offset <= shdr->sh_offset
3677 && (phdr->p_offset + phdr->p_filesz > shdr->sh_offset
3678 || (phdr->p_offset + phdr->p_memsz > shdr->sh_offset
3679 && shdr->sh_type == SHT_NOBITS)))
3683 < shdr->sh_offset + shdr->sh_size)
3688 if (shdr->sh_type == SHT_NOBITS)
3690 if (shdr->sh_offset < phdr->p_offset + phdr->p_filesz
3699 if (shdr->sh_offset > end ||
3700 (shdr->sh_offset == end && shdr->sh_size != 0))
3706 if (shdr->sh_type != SHT_NOBITS)
3708 if ((shdr->sh_flags & SHF_EXECINSTR) != 0)
3717 if ((shdr->sh_flags & SHF_WRITE) != 0)
3737 if (cnt == shstrndx && shdr->sh_type != SHT_STRTAB)
3742 switch (shdr->sh_type)
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);
3781 check_null (ebl, shdr, cnt);
3785 check_group (ebl, ehdr, shdr, cnt);
3789 check_note_section (ebl, ehdr, shdr, cnt);
3802 check_verneed (ebl, ehdr, shdr, cnt);
3806 check_verdef (ebl, shdr, cnt);
3810 check_attributes (ebl, ehdr, shdr, cnt);
3997 check_note_section (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
3999 if (shdr->sh_size == 0)
4021 else if (notes_size != shdr->sh_size)
4024 idx, section_name (ebl, idx), shdr->sh_size - notes_size);
4095 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
4096 if (shdr != NULL && shdr->sh_type == SHT_DYNAMIC)
4098 if (phdr->p_offset != shdr->sh_offset)
4101 if (phdr->p_memsz != shdr->sh_size)