Lines Matching refs:shdr
105 GElf_Shdr *shdr, int idx);
321 GElf_Shdr *shdr;
323 shdr = gelf_getshdr (elf_getscn (ebl->elf, idx), &shdr_mem);
325 return elf_strptr (ebl->elf, shstrndx, shdr->sh_name);
444 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (ebl->elf, 0), &shdr_mem);
445 if (shdr != NULL)
448 if (shdr->sh_size == 0)
452 shnum = shdr->sh_size;
461 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (ebl->elf, 0), &shdr_mem);
462 if (shdr != NULL && shdr->sh_link < shnum)
463 shstrndx = shdr->sh_link;
475 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (ebl->elf, 0), &shdr_mem);
476 if (shdr != NULL)
479 if (shdr->sh_info < PN_XNUM)
483 phnum = shdr->sh_info;
545 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
546 if (shdr == NULL)
552 if (shdr->sh_type != SHT_GROUP)
582 check_symtab (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
595 GElf_Shdr *strshdr = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
603 shdr->sh_link, section_name (ebl, shdr->sh_link),
635 if (shdr->sh_entsize != gelf_fsize (ebl->elf, ELF_T_SYM, 1, EV_CURRENT))
673 for (size_t cnt = 1; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
692 name = elf_strptr (ebl->elf, shdr->sh_link, sym->st_name);
749 if (cnt < shdr->sh_info)
872 if (cnt >= shdr->sh_info)
879 if (cnt < shdr->sh_info)
1010 && shdr->sh_type == SHT_DYNSYM)
1024 is_rel_dyn (Ebl *ebl, const GElf_Ehdr *ehdr, int idx, const GElf_Shdr *shdr,
1068 if (dyn->d_un.d_val > shdr->sh_size / shdr->sh_entsize)
1080 inner < shdr->sh_size / shdr->sh_entsize;
1120 if (dyn->d_un.d_val > shdr->sh_size / shdr->sh_entsize)
1132 inner < shdr->sh_size / shdr->sh_entsize;
1186 check_reloc_shdr (Ebl *ebl, const GElf_Ehdr *ehdr, const GElf_Shdr *shdr,
1193 if (shdr->sh_info >= shnum)
1196 else if (shdr->sh_info != 0)
1198 *destshdrp = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_info),
1205 reldyn = is_rel_dyn (ebl, ehdr, idx, shdr, true);
1214 if (shdr->sh_info != 0)
1228 if (shdr->sh_entsize != gelf_fsize (ebl->elf, reltype, 1, EV_CURRENT))
1428 check_rela (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
1442 bool reldyn = check_reloc_shdr (ebl, ehdr, shdr, idx, ELF_T_RELA, &destshdr,
1445 Elf_Scn *symscn = elf_getscn (ebl->elf, shdr->sh_link);
1451 for (size_t cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
1463 check_one_reloc (ebl, ehdr, shdr, idx, cnt, symshdr, symdata,
1478 check_rel (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
1492 bool reldyn = check_reloc_shdr (ebl, ehdr, shdr, idx, ELF_T_REL, &destshdr,
1495 Elf_Scn *symscn = elf_getscn (ebl->elf, shdr->sh_link);
1501 for (size_t cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
1513 check_one_reloc (ebl, ehdr, shdr, idx, cnt, symshdr, symdata,
1532 check_dynamic (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
1593 strshdr = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), &strshdr_mem);
1597 shdr->sh_link, section_name (ebl, shdr->sh_link),
1600 if (shdr->sh_entsize != gelf_fsize (ebl->elf, ELF_T_DYN, 1, EV_CURRENT))
1605 if (shdr->sh_info != 0)
1610 for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
1686 shdr->sh_link, section_name (ebl, shdr->sh_link));
1746 shdr->sh_link, section_name (ebl, shdr->sh_link));
1855 check_symtab_shndx (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
1865 Elf_Scn *symscn = elf_getscn (ebl->elf, shdr->sh_link);
1876 if (shdr->sh_entsize != sizeof (Elf32_Word))
1882 && (shdr->sh_size / shdr->sh_entsize
1888 if (shdr->sh_info != 0)
1897 && rshdr->sh_link == shdr->sh_link)
1936 check_sysv_hash (Ebl *ebl, GElf_Shdr *shdr, Elf_Data *data, int idx,
1942 if (shdr->sh_size < (2 + nbucket + nchain) * shdr->sh_entsize)
1945 idx, section_name (ebl, idx), (long int) shdr->sh_size,
1946 (long int) ((2 + nbucket + nchain) * shdr->sh_entsize));
1977 check_sysv_hash64 (Ebl *ebl, GElf_Shdr *shdr, Elf_Data *data, int idx,
1983 if (shdr->sh_size < (2 + nbucket + nchain) * shdr->sh_entsize)
1986 idx, section_name (ebl, idx), (long int) shdr->sh_size,
1987 (long int) ((2 + nbucket + nchain) * shdr->sh_entsize));
2018 check_gnu_hash (Ebl *ebl, GElf_Shdr *shdr, Elf_Data *data, int idx,
2035 if (shdr->sh_size < (4 + bitmask_words + nbuckets) * sizeof (Elf32_Word))
2039 idx, section_name (ebl, idx), (long int) shdr->sh_size,
2049 size_t maxidx = shdr->sh_size / sizeof (Elf32_Word) - (4 + bitmask_words
2056 Elf_Data *symdata = elf_getdata (elf_getscn (ebl->elf, shdr->sh_link), NULL);
2160 check_hash (int tag, Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
2179 GElf_Shdr *symshdr = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
2186 if (shdr->sh_entsize != (tag == SHT_GNU_HASH
2194 if ((shdr->sh_flags & SHF_ALLOC) == 0)
2198 if (shdr->sh_size < (tag == SHT_GNU_HASH ? 4 : 2) * (shdr->sh_entsize ?: 4))
2210 check_sysv_hash64 (ebl, shdr, data, idx, symshdr);
2212 check_sysv_hash (ebl, shdr, data, idx, symshdr);
2216 check_gnu_hash (ebl, shdr, data, idx, symshdr);
2361 check_null (Ebl *ebl, GElf_Shdr *shdr, int idx)
2364 if (extra && shdr->sh_##name != 0) \
2381 check_group (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
2392 Elf_Scn *symscn = elf_getscn (ebl->elf, shdr->sh_link);
2405 if (shdr->sh_info >= symshdr->sh_size / gelf_fsize (ebl->elf, ELF_T_SYM,
2411 if (shdr->sh_flags != 0)
2416 GElf_Sym *sym = gelf_getsym (elf_getdata (symscn, NULL), shdr->sh_info,
2429 && shdr->sh_entsize != elf32_fsize (ELF_T_WORD, 1, EV_CURRENT))
2581 GElf_Shdr *shdr = NULL;
2584 shdr = gelf_getshdr (scn, &shdr_mem);
2585 if (shdr != NULL
2586 && (shdr->sh_type == SHT_REL || shdr->sh_type == SHT_RELA)
2587 && shdr->sh_link == symscnndx)
2599 if (shdr->sh_type == SHT_REL)
2600 for (int i = 0; (size_t) i < shdr->sh_size / shdr->sh_entsize; ++i)
2612 for (int i = 0; (size_t) i < shdr->sh_size / shdr->sh_entsize; ++i)
2632 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (ebl->elf, shndx), &shdr_mem);
2633 return shdr != NULL && shdr->sh_type == SHT_NOBITS;
2679 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
2680 if (shdr == NULL)
2692 Elf_Scn *symscn = elf_getscn (ebl->elf, shdr->sh_link);
2704 shdr->sh_link, section_name (ebl, shdr->sh_link));
2710 if (shdr->sh_size / shdr->sh_entsize
2715 shdr->sh_link, section_name (ebl, shdr->sh_link));
2722 for (int cnt = 1; (size_t) cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
2779 if (!has_copy_reloc (ebl, shdr->sh_link, cnt)
2807 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
2809 if (shdr != NULL && shdr->sh_type == SHT_DYNAMIC && data != NULL)
2810 for (size_t j = 0; j < shdr->sh_size / shdr->sh_entsize; ++j)
2816 const char *str = elf_strptr (elf, shdr->sh_link, dyn->d_un.d_val);
2830 check_verneed (Ebl *ebl, GElf_Shdr *shdr, int idx)
2836 GElf_Shdr *strshdr = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
2853 for (int cnt = shdr->sh_info; --cnt >= 0; )
2874 const char *libname = elf_strptr (ebl->elf, shdr->sh_link,
2902 const char *verstr = elf_strptr (ebl->elf, shdr->sh_link,
2959 check_verdef (Ebl *ebl, GElf_Shdr *shdr, int idx)
2965 GElf_Shdr *strshdr = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
2996 for (int cnt = shdr->sh_info; --cnt >= 0; )
3038 const char *name = elf_strptr (ebl->elf, shdr->sh_link, aux->vda_name);
3074 name = elf_strptr (ebl->elf, shdr->sh_link, aux->vda_name);
3138 check_attributes (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
3140 if (shdr->sh_size == 0)
3408 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (ebl->elf, 0), &shdr_mem);
3409 if (shdr == NULL)
3413 if (shdr->sh_name != 0)
3415 if (shdr->sh_type != 0)
3417 if (shdr->sh_flags != 0)
3419 if (shdr->sh_addr != 0)
3421 if (shdr->sh_offset != 0)
3423 if (shdr->sh_addralign != 0)
3425 if (shdr->sh_entsize != 0)
3428 if (shdr->sh_size != 0 && ehdr->e_shnum != 0)
3432 if (shdr->sh_link != 0 && ehdr->e_shstrndx != SHN_XINDEX)
3436 if (shdr->sh_info != 0 && ehdr->e_phnum != PN_XNUM)
3451 shdr = gelf_getshdr (elf_getscn (ebl->elf, cnt), &shdr_mem);
3452 if (shdr == NULL)
3460 const char *scnname = elf_strptr (ebl->elf, shstrndx, shdr->sh_name);
3484 if (shdr->sh_type != good_type
3485 && (shdr->sh_type != SHT_NOBITS
3495 ebl_section_type_name (ebl, shdr->sh_type,
3503 if ((shdr->sh_flags & ~(SHF_LINK_ORDER | SHF_GROUP))
3511 section_flags_string (shdr->sh_flags
3517 if ((shdr->sh_flags & special_sections[s].attr)
3519 || ((shdr->sh_flags & ~(SHF_LINK_ORDER | SHF_GROUP
3530 section_flags_string (shdr->sh_flags
3545 if ((shdr->sh_flags & SHF_ALLOC) != 0
3550 else if ((shdr->sh_flags & SHF_ALLOC) == 0
3577 if ((shdr->sh_flags & SHF_ALLOC) != 0
3582 else if ((shdr->sh_flags & SHF_ALLOC) == 0
3602 if (shdr->sh_entsize != 0 && shdr->sh_size % shdr->sh_entsize)
3607 if (elf_strptr (ebl->elf, shstrndx, shdr->sh_name) == NULL)
3610 if (shdr->sh_type >= SHT_NUM
3611 && shdr->sh_type != SHT_GNU_ATTRIBUTES
3612 && shdr->sh_type != SHT_GNU_LIBLIST
3613 && shdr->sh_type != SHT_CHECKSUM
3614 && shdr->sh_type != SHT_GNU_verdef
3615 && shdr->sh_type != SHT_GNU_verneed
3616 && shdr->sh_type != SHT_GNU_versym
3617 && ebl_section_type_name (ebl, shdr->sh_type, NULL, 0) == NULL)
3620 (int) shdr->sh_type);
3625 if (shdr->sh_flags & ~(GElf_Xword) ALL_SH_FLAGS)
3627 GElf_Xword sh_flags = shdr->sh_flags & ~(GElf_Xword) ALL_SH_FLAGS;
3643 if (shdr->sh_flags & SHF_TLS)
3646 if (shdr->sh_addr != 0 && !gnuld)
3654 if (shdr->sh_link >= shnum)
3659 if (SH_INFO_LINK_P (shdr) && shdr->sh_info >= shnum)
3664 if ((shdr->sh_flags & SHF_MERGE) == 0
3665 && (shdr->sh_flags & SHF_STRINGS) != 0
3671 if ((shdr->sh_flags & SHF_MERGE) != 0 && shdr->sh_entsize == 0)
3676 if (shdr->sh_flags & SHF_GROUP)
3679 if (shdr->sh_flags & SHF_EXECINSTR)
3681 switch (shdr->sh_type)
3692 cnt, section_name (ebl, cnt), shdr->sh_type);
3696 if ((shdr->sh_flags & SHF_WRITE)
3697 && !ebl_check_special_section (ebl, cnt, shdr,
3704 if (ehdr->e_type != ET_REL && (shdr->sh_flags & SHF_ALLOC) != 0)
3715 && (shdr->sh_flags & SHF_TLS) == 0)
3717 && (shdr->sh_flags & SHF_TLS) != 0))
3718 && phdr->p_offset <= shdr->sh_offset
3719 && (phdr->p_offset + phdr->p_filesz > shdr->sh_offset
3720 || (phdr->p_offset + phdr->p_memsz > shdr->sh_offset
3721 && shdr->sh_type == SHT_NOBITS)))
3725 < shdr->sh_offset + shdr->sh_size)
3730 if (shdr->sh_type == SHT_NOBITS)
3732 if (shdr->sh_offset < phdr->p_offset + phdr->p_filesz
3741 if (shdr->sh_offset > end ||
3742 (shdr->sh_offset == end && shdr->sh_size != 0))
3748 if (shdr->sh_type != SHT_NOBITS)
3750 if ((shdr->sh_flags & SHF_EXECINSTR) != 0)
3759 if ((shdr->sh_flags & SHF_WRITE) != 0)
3779 if (cnt == shstrndx && shdr->sh_type != SHT_STRTAB)
3784 switch (shdr->sh_type)
3793 check_symtab (ebl, ehdr, shdr, cnt);
3797 check_rela (ebl, ehdr, shdr, cnt);
3801 check_rel (ebl, ehdr, shdr, cnt);
3805 check_dynamic (ebl, ehdr, shdr, cnt);
3809 check_symtab_shndx (ebl, ehdr, shdr, cnt);
3813 check_hash (shdr->sh_type, ebl, ehdr, shdr, cnt);
3818 check_hash (shdr->sh_type, ebl, ehdr, shdr, cnt);
3823 check_null (ebl, shdr, cnt);
3827 check_group (ebl, ehdr, shdr, cnt);
3831 check_note_section (ebl, ehdr, shdr, cnt);
3844 check_verneed (ebl, shdr, cnt);
3848 check_verdef (ebl, shdr, cnt);
3852 check_attributes (ebl, ehdr, shdr, cnt);
4042 check_note_section (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
4044 if (shdr->sh_size == 0)
4066 else if (notes_size != shdr->sh_size)
4069 idx, section_name (ebl, idx), shdr->sh_size - notes_size);
4145 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
4146 if (shdr != NULL && shdr->sh_type == SHT_DYNAMIC)
4148 if (phdr->p_offset != shdr->sh_offset)
4151 if (phdr->p_memsz != shdr->sh_size)
4232 GElf_Shdr *shdr = NULL;
4237 shdr = gelf_getshdr (scn, &shdr_mem);
4238 if (shdr != NULL
4239 && shdr->sh_type == (is_debuginfo
4242 elf_strptr (ebl->elf, shstrndx, shdr->sh_name)))
4246 if (phdr->p_offset != shdr->sh_offset)
4249 if (phdr->p_memsz != shdr->sh_size)
4273 else if (shdr != NULL && (shdr->sh_flags & SHF_ALLOC) == 0)
4280 else if (shdr != NULL && (shdr->sh_flags & SHF_WRITE) != 0)
4288 else if (shdr != NULL && (shdr->sh_flags & SHF_EXECINSTR) != 0)