Lines Matching refs:shdr
97 GElf_Shdr *shdr, int idx);
317 GElf_Shdr *shdr; in section_name() local
323 shdr = gelf_getshdr (elf_getscn (ebl->elf, idx), &shdr_mem); in section_name()
324 if (shdr == NULL) in section_name()
327 ret = elf_strptr (ebl->elf, shstrndx, shdr->sh_name); in section_name()
447 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (ebl->elf, 0), &shdr_mem); in check_elf_header() local
448 if (shdr != NULL) in check_elf_header()
451 if (shdr->sh_size == 0) in check_elf_header()
455 shnum = shdr->sh_size; in check_elf_header()
464 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (ebl->elf, 0), &shdr_mem); in check_elf_header() local
465 if (shdr != NULL && shdr->sh_link < shnum) in check_elf_header()
466 shstrndx = shdr->sh_link; in check_elf_header()
478 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (ebl->elf, 0), &shdr_mem); in check_elf_header() local
479 if (shdr != NULL) in check_elf_header()
482 if (shdr->sh_info < PN_XNUM) in check_elf_header()
486 phnum = shdr->sh_info; in check_elf_header()
548 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); in check_scn_group() local
549 if (shdr == NULL) in check_scn_group()
555 if (shdr->sh_type != SHT_GROUP) in check_scn_group()
586 check_symtab (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx) in check_symtab() argument
599 GElf_Shdr *strshdr = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), in check_symtab()
607 shdr->sh_link, section_name (ebl, shdr->sh_link), in check_symtab()
640 if (shdr->sh_entsize != sh_entsize) in check_symtab()
678 for (size_t cnt = 1; cnt < shdr->sh_size / sh_entsize; ++cnt) in check_symtab()
697 name = elf_strptr (ebl->elf, shdr->sh_link, sym->st_name); in check_symtab()
755 if (cnt < shdr->sh_info) in check_symtab()
903 if (cnt >= shdr->sh_info) in check_symtab()
910 if (cnt < shdr->sh_info) in check_symtab()
1041 && shdr->sh_type == SHT_DYNSYM) in check_symtab()
1055 is_rel_dyn (Ebl *ebl, const GElf_Ehdr *ehdr, int idx, const GElf_Shdr *shdr, in is_rel_dyn() argument
1108 if (shdr->sh_entsize != 0 in is_rel_dyn()
1109 && dyn->d_un.d_val > (shdr->sh_size in is_rel_dyn()
1110 / shdr->sh_entsize)) in is_rel_dyn()
1120 if (reldata != NULL && shdr->sh_entsize != 0) in is_rel_dyn()
1122 inner < shdr->sh_size / shdr->sh_entsize; in is_rel_dyn()
1162 if (shdr->sh_entsize != 0 in is_rel_dyn()
1163 && dyn->d_un.d_val > shdr->sh_size / shdr->sh_entsize) in is_rel_dyn()
1173 if (reldata != NULL && shdr->sh_entsize != 0) in is_rel_dyn()
1175 inner < shdr->sh_size / shdr->sh_entsize; in is_rel_dyn()
1229 check_reloc_shdr (Ebl *ebl, const GElf_Ehdr *ehdr, const GElf_Shdr *shdr, in check_reloc_shdr() argument
1236 if (shdr->sh_info >= shnum) in check_reloc_shdr()
1239 else if (shdr->sh_info != 0) in check_reloc_shdr()
1241 *destshdrp = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_info), in check_reloc_shdr()
1247 reldyn = is_rel_dyn (ebl, ehdr, idx, shdr, true); in check_reloc_shdr()
1256 if (shdr->sh_info != 0) in check_reloc_shdr()
1272 if (shdr->sh_entsize != sh_entsize) in check_reloc_shdr()
1472 check_rela (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx) in check_rela() argument
1486 bool reldyn = check_reloc_shdr (ebl, ehdr, shdr, idx, ELF_T_RELA, &destshdr, in check_rela()
1489 Elf_Scn *symscn = elf_getscn (ebl->elf, shdr->sh_link); in check_rela()
1496 for (size_t cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt) in check_rela()
1508 check_one_reloc (ebl, ehdr, shdr, idx, cnt, symshdr, symdata, in check_rela()
1523 check_rel (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx) in check_rel() argument
1537 bool reldyn = check_reloc_shdr (ebl, ehdr, shdr, idx, ELF_T_REL, &destshdr, in check_rel()
1540 Elf_Scn *symscn = elf_getscn (ebl->elf, shdr->sh_link); in check_rel()
1547 for (size_t cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt) in check_rel()
1559 check_one_reloc (ebl, ehdr, shdr, idx, cnt, symshdr, symdata, in check_rel()
1578 check_dynamic (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx) in check_dynamic() argument
1639 strshdr = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), &strshdr_mem); in check_dynamic()
1643 shdr->sh_link, section_name (ebl, shdr->sh_link), in check_dynamic()
1649 shdr->sh_link, idx, section_name (ebl, idx)); in check_dynamic()
1654 if (shdr->sh_entsize != sh_entsize) in check_dynamic()
1659 if (shdr->sh_info != 0) in check_dynamic()
1664 for (cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt) in check_dynamic()
1740 shdr->sh_link, section_name (ebl, shdr->sh_link)); in check_dynamic()
1800 shdr->sh_link, section_name (ebl, shdr->sh_link)); in check_dynamic()
1909 check_symtab_shndx (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx) in check_symtab_shndx() argument
1919 Elf_Scn *symscn = elf_getscn (ebl->elf, shdr->sh_link); in check_symtab_shndx()
1929 idx, section_name (ebl, idx), shdr->sh_link); in check_symtab_shndx()
1934 if (shdr->sh_entsize != sizeof (Elf32_Word)) in check_symtab_shndx()
1940 && shdr->sh_entsize != 0 in check_symtab_shndx()
1942 && (shdr->sh_size / shdr->sh_entsize in check_symtab_shndx()
1948 if (shdr->sh_info != 0) in check_symtab_shndx()
1957 && rshdr->sh_link == shdr->sh_link) in check_symtab_shndx()
2002 check_sysv_hash (Ebl *ebl, GElf_Shdr *shdr, Elf_Data *data, int idx, in check_sysv_hash() argument
2008 if (shdr->sh_size < (2 + nbucket + nchain) * shdr->sh_entsize) in check_sysv_hash()
2011 idx, section_name (ebl, idx), (long int) shdr->sh_size, in check_sysv_hash()
2012 (long int) ((2 + nbucket + nchain) * shdr->sh_entsize)); in check_sysv_hash()
2028 Elf32_Word *end = (Elf32_Word *) ((char *) data->d_buf + shdr->sh_size); in check_sysv_hash()
2053 check_sysv_hash64 (Ebl *ebl, GElf_Shdr *shdr, Elf_Data *data, int idx, in check_sysv_hash64() argument
2059 if (shdr->sh_size < (2 + nbucket + nchain) * shdr->sh_entsize) in check_sysv_hash64()
2062 idx, section_name (ebl, idx), (long int) shdr->sh_size, in check_sysv_hash64()
2063 (long int) ((2 + nbucket + nchain) * shdr->sh_entsize)); in check_sysv_hash64()
2079 Elf64_Xword *end = (Elf64_Xword *) ((char *) data->d_buf + shdr->sh_size); in check_sysv_hash64()
2104 check_gnu_hash (Ebl *ebl, GElf_Shdr *shdr, Elf_Data *data, int idx, in check_gnu_hash() argument
2139 idx, section_name (ebl, idx), (long int) shdr->sh_size, in check_gnu_hash()
2152 size_t maxidx = shdr->sh_size / sizeof (Elf32_Word) - (4 + bitmask_words in check_gnu_hash()
2159 Elf_Data *symdata = elf_getdata (elf_getscn (ebl->elf, shdr->sh_link), NULL); in check_gnu_hash()
2273 check_hash (int tag, Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx) in check_hash() argument
2292 GElf_Shdr *symshdr = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), in check_hash()
2301 idx, section_name (ebl, idx), shdr->sh_link); in check_hash()
2303 if (shdr->sh_entsize != (tag == SHT_GNU_HASH in check_hash()
2311 if ((shdr->sh_flags & SHF_ALLOC) == 0) in check_hash()
2315 if (shdr->sh_size < (tag == SHT_GNU_HASH ? 4 : 2) * (shdr->sh_entsize ?: 4)) in check_hash()
2327 check_sysv_hash64 (ebl, shdr, data, idx, symshdr); in check_hash()
2329 check_sysv_hash (ebl, shdr, data, idx, symshdr); in check_hash()
2333 check_gnu_hash (ebl, shdr, data, idx, symshdr); in check_hash()
2569 check_null (Ebl *ebl, GElf_Shdr *shdr, int idx) in check_null() argument
2572 if (extra && shdr->sh_##name != 0) \ in check_null()
2589 check_group (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx) in check_group() argument
2600 Elf_Scn *symscn = elf_getscn (ebl->elf, shdr->sh_link); in check_group()
2613 if (shdr->sh_info >= symshdr->sh_size / gelf_fsize (ebl->elf, ELF_T_SYM, in check_group()
2619 if (shdr->sh_flags != 0) in check_group()
2624 GElf_Sym *sym = gelf_getsym (elf_getdata (symscn, NULL), shdr->sh_info, in check_group()
2641 && shdr->sh_entsize != elf32_fsize (ELF_T_WORD, 1, EV_CURRENT)) in check_group()
2794 GElf_Shdr *shdr = NULL; in has_copy_reloc() local
2797 shdr = gelf_getshdr (scn, &shdr_mem); in has_copy_reloc()
2798 if (shdr != NULL in has_copy_reloc()
2799 && (shdr->sh_type == SHT_REL || shdr->sh_type == SHT_RELA) in has_copy_reloc()
2800 && shdr->sh_link == symscnndx) in has_copy_reloc()
2809 if (data == NULL || shdr->sh_entsize == 0) in has_copy_reloc()
2812 if (shdr->sh_type == SHT_REL) in has_copy_reloc()
2813 for (int i = 0; (size_t) i < shdr->sh_size / shdr->sh_entsize; ++i) in has_copy_reloc()
2825 for (int i = 0; (size_t) i < shdr->sh_size / shdr->sh_entsize; ++i) in has_copy_reloc()
2845 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (ebl->elf, shndx), &shdr_mem); in in_nobits_scn() local
2846 return shdr != NULL && shdr->sh_type == SHT_NOBITS; in in_nobits_scn()
2892 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); in check_versym() local
2893 if (shdr == NULL) in check_versym()
2905 Elf_Scn *symscn = elf_getscn (ebl->elf, shdr->sh_link); in check_versym()
2917 shdr->sh_link, section_name (ebl, shdr->sh_link)); in check_versym()
2923 if (shdr->sh_entsize != 0 && symshdr->sh_entsize != 0 in check_versym()
2924 && (shdr->sh_size / shdr->sh_entsize in check_versym()
2929 shdr->sh_link, section_name (ebl, shdr->sh_link)); in check_versym()
2932 if (symdata == NULL || shdr->sh_entsize == 0) in check_versym()
2936 for (int cnt = 1; (size_t) cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) in check_versym()
2993 if (!has_copy_reloc (ebl, shdr->sh_link, cnt) in check_versym()
3021 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); in unknown_dependency_p() local
3023 if (shdr != NULL && shdr->sh_type == SHT_DYNAMIC in unknown_dependency_p()
3024 && data != NULL && shdr->sh_entsize != 0) in unknown_dependency_p()
3025 for (size_t j = 0; j < shdr->sh_size / shdr->sh_entsize; ++j) in unknown_dependency_p()
3031 const char *str = elf_strptr (elf, shdr->sh_link, dyn->d_un.d_val); in unknown_dependency_p()
3045 check_verneed (Ebl *ebl, GElf_Shdr *shdr, int idx) in check_verneed() argument
3051 GElf_Shdr *strshdr = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), in check_verneed()
3068 for (Elf64_Word cnt = shdr->sh_info; cnt > 0; ) in check_verneed()
3094 const char *libname = elf_strptr (ebl->elf, shdr->sh_link, in check_verneed()
3122 const char *verstr = elf_strptr (ebl->elf, shdr->sh_link, in check_verneed()
3192 check_verdef (Ebl *ebl, GElf_Shdr *shdr, int idx) in check_verdef() argument
3198 GElf_Shdr *strshdr = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), in check_verdef()
3229 for (Elf64_Word cnt = shdr->sh_info; cnt > 0; ) in check_verdef()
3276 const char *name = elf_strptr (ebl->elf, shdr->sh_link, aux->vda_name); in check_verdef()
3311 name = elf_strptr (ebl->elf, shdr->sh_link, aux->vda_name); in check_verdef()
3389 check_attributes (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx) in check_attributes() argument
3391 if (shdr->sh_size == 0) in check_attributes()
3661 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (ebl->elf, 0), &shdr_mem); in check_sections() local
3662 if (shdr == NULL) in check_sections()
3666 if (shdr->sh_name != 0) in check_sections()
3668 if (shdr->sh_type != 0) in check_sections()
3670 if (shdr->sh_flags != 0) in check_sections()
3672 if (shdr->sh_addr != 0) in check_sections()
3674 if (shdr->sh_offset != 0) in check_sections()
3676 if (shdr->sh_addralign != 0) in check_sections()
3678 if (shdr->sh_entsize != 0) in check_sections()
3681 if (shdr->sh_size != 0 && ehdr->e_shnum != 0) in check_sections()
3685 if (shdr->sh_link != 0 && ehdr->e_shstrndx != SHN_XINDEX) in check_sections()
3689 if (shdr->sh_info != 0 && ehdr->e_phnum != PN_XNUM) in check_sections()
3705 shdr = gelf_getshdr (scn, &shdr_mem); in check_sections()
3706 if (shdr == NULL) in check_sections()
3714 const char *scnname = elf_strptr (ebl->elf, shstrndx, shdr->sh_name); in check_sections()
3738 if (shdr->sh_type != good_type in check_sections()
3739 && (shdr->sh_type != SHT_NOBITS in check_sections()
3749 ebl_section_type_name (ebl, shdr->sh_type, in check_sections()
3758 if ((shdr->sh_flags in check_sections()
3767 section_flags_string (shdr->sh_flags in check_sections()
3773 if ((shdr->sh_flags & special_sections[s].attr) in check_sections()
3775 || ((shdr->sh_flags in check_sections()
3787 section_flags_string (shdr->sh_flags in check_sections()
3802 if ((shdr->sh_flags & SHF_ALLOC) != 0 in check_sections()
3807 else if ((shdr->sh_flags & SHF_ALLOC) == 0 in check_sections()
3834 if ((shdr->sh_flags & SHF_ALLOC) != 0 in check_sections()
3839 else if ((shdr->sh_flags & SHF_ALLOC) == 0 in check_sections()
3859 if (shdr->sh_entsize != 0 && shdr->sh_size % shdr->sh_entsize) in check_sections()
3864 if (elf_strptr (ebl->elf, shstrndx, shdr->sh_name) == NULL) in check_sections()
3867 if (shdr->sh_type >= SHT_NUM in check_sections()
3868 && shdr->sh_type != SHT_GNU_ATTRIBUTES in check_sections()
3869 && shdr->sh_type != SHT_GNU_LIBLIST in check_sections()
3870 && shdr->sh_type != SHT_CHECKSUM in check_sections()
3871 && shdr->sh_type != SHT_GNU_verdef in check_sections()
3872 && shdr->sh_type != SHT_GNU_verneed in check_sections()
3873 && shdr->sh_type != SHT_GNU_versym in check_sections()
3874 && ebl_section_type_name (ebl, shdr->sh_type, NULL, 0) == NULL) in check_sections()
3877 (int) shdr->sh_type); in check_sections()
3883 if (shdr->sh_flags & ~(GElf_Xword) ALL_SH_FLAGS) in check_sections()
3885 GElf_Xword sh_flags = shdr->sh_flags & ~(GElf_Xword) ALL_SH_FLAGS; in check_sections()
3901 if (shdr->sh_flags & SHF_TLS) in check_sections()
3904 if (shdr->sh_addr != 0 && !gnuld) in check_sections()
3912 if (shdr->sh_flags & SHF_COMPRESSED) in check_sections()
3914 if (shdr->sh_flags & SHF_ALLOC) in check_sections()
3919 if (shdr->sh_type == SHT_NOBITS) in check_sections()
3931 if (shdr->sh_link >= shnum) in check_sections()
3936 if (SH_INFO_LINK_P (shdr) && shdr->sh_info >= shnum) in check_sections()
3941 if ((shdr->sh_flags & SHF_MERGE) == 0 in check_sections()
3942 && (shdr->sh_flags & SHF_STRINGS) != 0 in check_sections()
3948 if ((shdr->sh_flags & SHF_MERGE) != 0 && shdr->sh_entsize == 0) in check_sections()
3953 if (shdr->sh_flags & SHF_GROUP) in check_sections()
3956 if (shdr->sh_flags & SHF_EXECINSTR) in check_sections()
3958 switch (shdr->sh_type) in check_sections()
3969 cnt, section_name (ebl, cnt), shdr->sh_type); in check_sections()
3973 if (shdr->sh_flags & SHF_WRITE) in check_sections()
3975 if (is_debuginfo && shdr->sh_type != SHT_NOBITS) in check_sections()
3981 && !ebl_check_special_section (ebl, cnt, shdr, in check_sections()
3989 if (ehdr->e_type != ET_REL && (shdr->sh_flags & SHF_ALLOC) != 0 in check_sections()
4001 && (shdr->sh_flags & SHF_TLS) == 0) in check_sections()
4003 && (shdr->sh_flags & SHF_TLS) != 0)) in check_sections()
4004 && phdr->p_offset <= shdr->sh_offset in check_sections()
4005 && ((shdr->sh_offset - phdr->p_offset <= phdr->p_filesz in check_sections()
4006 && (shdr->sh_offset - phdr->p_offset < phdr->p_filesz in check_sections()
4007 || shdr->sh_size == 0)) in check_sections()
4008 || (shdr->sh_offset - phdr->p_offset < phdr->p_memsz in check_sections()
4009 && shdr->sh_type == SHT_NOBITS))) in check_sections()
4013 < shdr->sh_offset + shdr->sh_size) in check_sections()
4018 if (shdr->sh_type == SHT_NOBITS) in check_sections()
4020 if (shdr->sh_offset < phdr->p_offset + phdr->p_filesz in check_sections()
4039 shdr->sh_offset, in check_sections()
4040 shdr->sh_size, in check_sections()
4043 || databits->d_size != shdr->sh_size); in check_sections()
4059 if (shdr->sh_offset > end || in check_sections()
4060 (shdr->sh_offset == end && shdr->sh_size != 0)) in check_sections()
4066 if (shdr->sh_type != SHT_NOBITS) in check_sections()
4068 if ((shdr->sh_flags & SHF_EXECINSTR) != 0) in check_sections()
4077 if ((shdr->sh_flags & SHF_WRITE) != 0) in check_sections()
4097 if (cnt == shstrndx && shdr->sh_type != SHT_STRTAB) in check_sections()
4102 switch (shdr->sh_type) in check_sections()
4111 check_symtab (ebl, ehdr, shdr, cnt); in check_sections()
4115 check_rela (ebl, ehdr, shdr, cnt); in check_sections()
4119 check_rel (ebl, ehdr, shdr, cnt); in check_sections()
4123 check_dynamic (ebl, ehdr, shdr, cnt); in check_sections()
4127 check_symtab_shndx (ebl, ehdr, shdr, cnt); in check_sections()
4131 check_hash (shdr->sh_type, ebl, ehdr, shdr, cnt); in check_sections()
4136 check_hash (shdr->sh_type, ebl, ehdr, shdr, cnt); in check_sections()
4141 check_null (ebl, shdr, cnt); in check_sections()
4145 check_group (ebl, ehdr, shdr, cnt); in check_sections()
4149 check_note_section (ebl, ehdr, shdr, cnt); in check_sections()
4162 check_verneed (ebl, shdr, cnt); in check_sections()
4166 check_verdef (ebl, shdr, cnt); in check_sections()
4170 check_attributes (ebl, ehdr, shdr, cnt); in check_sections()
4360 check_note_section (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx) in check_note_section() argument
4362 if (shdr->sh_size == 0) in check_note_section()
4384 else if (notes_size != shdr->sh_size) in check_note_section()
4387 idx, section_name (ebl, idx), shdr->sh_size - notes_size); in check_note_section()
4463 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); in check_program_header() local
4464 if (shdr != NULL && shdr->sh_type == SHT_DYNAMIC) in check_program_header()
4466 if (phdr->p_offset != shdr->sh_offset) in check_program_header()
4469 if (phdr->p_memsz != shdr->sh_size) in check_program_header()
4566 GElf_Shdr *shdr = NULL; in check_program_header() local
4571 shdr = gelf_getshdr (scn, &shdr_mem); in check_program_header()
4572 if (shdr != NULL in check_program_header()
4573 && shdr->sh_type == (is_debuginfo in check_program_header()
4575 && elf_strptr (ebl->elf, shstrndx, shdr->sh_name) != NULL in check_program_header()
4577 elf_strptr (ebl->elf, shstrndx, shdr->sh_name))) in check_program_header()
4581 if (phdr->p_offset != shdr->sh_offset) in check_program_header()
4584 if (phdr->p_memsz != shdr->sh_size) in check_program_header()
4608 else if (shdr != NULL && (shdr->sh_flags & SHF_ALLOC) == 0) in check_program_header()
4615 else if (shdr != NULL && (shdr->sh_flags & SHF_WRITE) != 0) in check_program_header()
4623 else if (shdr != NULL && (shdr->sh_flags & SHF_EXECINSTR) != 0) in check_program_header()