Lines Matching refs:shdr
355 section_can_shrink (const GElf_Shdr *shdr) in section_can_shrink() argument
357 switch (shdr->sh_type) in section_can_shrink()
386 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (elf, i), &shdr_mem); in symtab_count_leading_section_symbols() local
387 ELF_CHECK (shdr != NULL, _("cannot get section header: %s")); in symtab_count_leading_section_symbols()
395 sym->st_value = shdr->sh_addr; in symtab_count_leading_section_symbols()
427 adjust_relocs (Elf_Scn *outscn, Elf_Scn *inscn, const GElf_Shdr *shdr, in adjust_relocs() argument
439 switch (shdr->sh_type) in adjust_relocs()
442 for (size_t i = 0; i < shdr->sh_size / shdr->sh_entsize; ++i) in adjust_relocs()
453 for (size_t i = 0; i < shdr->sh_size / shdr->sh_entsize; ++i) in adjust_relocs()
480 const size_t onent = shdr->sh_size / shdr->sh_entsize; in adjust_relocs()
481 assert (data->d_size == shdr->sh_size); in adjust_relocs()
512 switch (shdr->sh_entsize) in adjust_relocs()
535 const size_t onent = shdr->sh_size / shdr->sh_entsize; in adjust_relocs()
552 data->d_size = nent * shdr->sh_entsize; in adjust_relocs()
576 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); in adjust_all_relocs() local
577 ELF_CHECK (shdr != NULL, _("cannot get section header: %s")); in adjust_all_relocs()
578 if (shdr->sh_type != SHT_NOBITS && shdr->sh_link == new_sh_link) in adjust_all_relocs()
579 adjust_relocs (scn, scn, shdr, map, symshdr); in adjust_all_relocs()
593 GElf_Shdr *shdr = gelf_getshdr (symscn, &shdr_mem); in add_new_section_symbols() local
594 ELF_CHECK (shdr != NULL, _("cannot get section header: %s")); in add_new_section_symbols()
596 const size_t nsym = shdr->sh_size / shdr->sh_entsize; in add_new_section_symbols()
599 shdr->sh_info += added; in add_new_section_symbols()
600 shdr->sh_size += added * shdr->sh_entsize; in add_new_section_symbols()
601 update_shdr (symscn, shdr); in add_new_section_symbols()
606 symdata->d_size = shdr->sh_size; in add_new_section_symbols()
659 adjust_all_relocs (elf, symscn, shdr, symndx_map); in add_new_section_symbols()
690 GElf_Shdr shdr; member
700 if (s1->shdr.sh_addr < s2->shdr.sh_addr) in compare_alloc_sections()
702 if (s1->shdr.sh_addr > s2->shdr.sh_addr) in compare_alloc_sections()
731 if ((s1->shdr.sh_flags ^ s2->shdr.sh_flags) & SHF_ALLOC) in compare_sections()
732 return (s1->shdr.sh_flags & SHF_ALLOC) ? -1 : 1; in compare_sections()
734 return ((s1->shdr.sh_flags & SHF_ALLOC) in compare_sections()
736 : compare_unalloc_sections (&s1->shdr, &s2->shdr, in compare_sections()
827 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (outelf, s->shndx), in collect_symbols() local
829 ELF_CHECK (shdr != NULL, _("cannot get section header: %s")); in collect_symbols()
830 s->value = shdr->sh_addr; in collect_symbols()
833 && s->value < split_bss->shdr.sh_addr in collect_symbols()
834 && s->value >= split_bss[-1].shdr.sh_addr in collect_symbols()
923 const GElf_Shdr *shdr, const char *name) in sections_match() argument
925 return (sections_flags_match (sections[i].shdr.sh_flags, shdr->sh_flags, in sections_match()
926 sections[i].shdr.sh_type) in sections_match()
927 && (sections[i].shdr.sh_size == shdr->sh_size in sections_match()
928 || (sections[i].shdr.sh_size < shdr->sh_size in sections_match()
929 && section_can_shrink (§ions[i].shdr))) in sections_match()
935 find_alloc_section (const GElf_Shdr *shdr, GElf_Addr bias, const char *name, in find_alloc_section() argument
938 const GElf_Addr addr = shdr->sh_addr + bias; in find_alloc_section()
943 if (addr < sections[i].shdr.sh_addr) in find_alloc_section()
945 else if (addr > sections[i].shdr.sh_addr) in find_alloc_section()
951 while (i > 0 && sections[i - 1].shdr.sh_addr == addr) in find_alloc_section()
953 for (; i < nalloc && sections[i].shdr.sh_addr == addr; in find_alloc_section()
955 if (sections_match (sections, i, shdr, name)) in find_alloc_section()
964 get_section_name (size_t ndx, const GElf_Shdr *shdr, const Elf_Data *shstrtab) in get_section_name() argument
966 if (shdr->sh_name >= shstrtab->d_size) in get_section_name()
969 return shstrtab->d_buf + shdr->sh_name; in get_section_name()
988 if (sec->shdr.sh_type == SHT_PROGBITS in find_alloc_sections_prelink()
989 && !(sec->shdr.sh_flags & SHF_ALLOC) in find_alloc_sections_prelink()
1057 void *shdr = xmalloc (shdr_bytes); in find_alloc_sections_prelink() local
1058 dst.d_buf = shdr; in find_alloc_sections_prelink()
1068 Elf32_Shdr (*s32)[shnum - 1] = shdr; in find_alloc_sections_prelink()
1069 Elf64_Shdr (*s64)[shnum - 1] = shdr; in find_alloc_sections_prelink()
1072 #define COPY(field) sec->shdr.field = (*s32)[i].field in find_alloc_sections_prelink()
1086 sec->shdr = (*s64)[i]; in find_alloc_sections_prelink()
1087 if (sec->shdr.sh_flags & SHF_ALLOC) in find_alloc_sections_prelink()
1089 sec->shdr.sh_addr += bias; in find_alloc_sections_prelink()
1090 sec->name = get_section_name (i + 1, &sec->shdr, main_shstrtab); in find_alloc_sections_prelink()
1099 free (shdr); in find_alloc_sections_prelink()
1117 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); in find_alloc_sections_prelink() local
1118 ELF_CHECK (shdr != NULL, _("cannot get section header: %s")); in find_alloc_sections_prelink()
1120 if (!(shdr->sh_flags & SHF_ALLOC)) in find_alloc_sections_prelink()
1123 const char *name = get_section_name (elf_ndxscn (scn), shdr, in find_alloc_sections_prelink()
1128 struct section *sec = find_alloc_section (shdr, 0, name, in find_alloc_sections_prelink()
1140 for (size_t i = 0; shdr != NULL && i < nalloc; ++i) in find_alloc_sections_prelink()
1142 shdr = NULL; in find_alloc_sections_prelink()
1143 check_match (shdr == NULL, scn, name); in find_alloc_sections_prelink()
1164 (2 * sec->shdr.field == 3 * undo_sec->shdr.field) in find_alloc_sections_prelink()
1166 && sec->shdr.sh_name == undo_sec->shdr.sh_name in find_alloc_sections_prelink()
1167 && sec->shdr.sh_flags == undo_sec->shdr.sh_flags in find_alloc_sections_prelink()
1168 && sec->shdr.sh_addralign == undo_sec->shdr.sh_addralign in find_alloc_sections_prelink()
1169 && (((sec->shdr.sh_type == undo_sec->shdr.sh_type in find_alloc_sections_prelink()
1170 && sec->shdr.sh_entsize == undo_sec->shdr.sh_entsize in find_alloc_sections_prelink()
1171 && (sec->shdr.sh_size == undo_sec->shdr.sh_size in find_alloc_sections_prelink()
1172 || (sec->shdr.sh_size > undo_sec->shdr.sh_size in find_alloc_sections_prelink()
1175 || (sec->shdr.sh_size == undo_sec->shdr.sh_size in find_alloc_sections_prelink()
1176 && ((sec->shdr.sh_entsize == undo_sec->shdr.sh_entsize in find_alloc_sections_prelink()
1177 && undo_sec->shdr.sh_type == SHT_NOBITS) in find_alloc_sections_prelink()
1178 || undo_sec->shdr.sh_type == SHT_PROGBITS) in find_alloc_sections_prelink()
1180 || (sec->shdr.sh_type == SHT_RELA in find_alloc_sections_prelink()
1181 && undo_sec->shdr.sh_type == SHT_REL in find_alloc_sections_prelink()
1183 || (sec->shdr.sh_entsize == undo_sec->shdr.sh_entsize in find_alloc_sections_prelink()
1184 && (sec->shdr.sh_type == undo_sec->shdr.sh_type in find_alloc_sections_prelink()
1185 || (sec->shdr.sh_type == SHT_PROGBITS in find_alloc_sections_prelink()
1186 && undo_sec->shdr.sh_type == SHT_NOBITS)) in find_alloc_sections_prelink()
1187 && sec->shdr.sh_size <= undo_sec->shdr.sh_size in find_alloc_sections_prelink()
1190 && (sec->shdr.sh_size == undo_sec->shdr.sh_size in find_alloc_sections_prelink()
1244 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); in new_shstrtab() local
1245 const char *name = get_section_name (i + 1, shdr, shstrtab); in new_shstrtab()
1266 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); in new_shstrtab() local
1267 shdr->sh_name = ebl_strtaboffset (unstripped_strent[i]); in new_shstrtab()
1269 shdr->sh_size = strtab_data->d_size; in new_shstrtab()
1270 update_shdr (scn, shdr); in new_shstrtab()
1308 GElf_Shdr *shdr = gelf_getshdr (scn, §ions[i].shdr); in copy_elided_sections() local
1309 ELF_CHECK (shdr != NULL, _("cannot get section header: %s")); in copy_elided_sections()
1311 shdr->sh_name); in copy_elided_sections()
1327 while (nalloc > 0 && !(sections[nalloc - 1].shdr.sh_flags & SHF_ALLOC)) in copy_elided_sections()
1330 if (sections[nalloc].shdr.sh_type == SHT_SYMTAB) in copy_elided_sections()
1335 inline struct section *find_unalloc_section (const GElf_Shdr *shdr, in copy_elided_sections()
1343 int cmp = compare_unalloc_sections (shdr, &sec->shdr, in copy_elided_sections()
1368 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); in copy_elided_sections() local
1369 ELF_CHECK (shdr != NULL, _("cannot get section header: %s")); in copy_elided_sections()
1371 if (shdr->sh_type == SHT_SYMTAB) in copy_elided_sections()
1381 const char *name = get_section_name (ndx, shdr, shstrtab); in copy_elided_sections()
1384 if (shdr->sh_flags & SHF_ALLOC) in copy_elided_sections()
1389 sec = find_alloc_section (shdr, bias, name, sections, nalloc); in copy_elided_sections()
1401 if (likely (sections_match (sections, alloc_avail, shdr, name))) in copy_elided_sections()
1405 if (sections_match (sections, i, shdr, name)) in copy_elided_sections()
1415 sec = find_unalloc_section (shdr, name); in copy_elided_sections()
1421 if (shdr->sh_type != SHT_NOBITS) in copy_elided_sections()
1485 && secndx == stripped_symtab->shdr.sh_link) in copy_elided_sections()
1489 GElf_Shdr *shdr = gelf_getshdr (unstripped_symtab, &shdr_mem); in copy_elided_sections() local
1490 ELF_CHECK (shdr != NULL, _("cannot get section header: %s")); in copy_elided_sections()
1491 ndx_section[secndx - 1] = shdr->sh_link; in copy_elided_sections()
1495 if (!(sec->shdr.sh_flags & SHF_ALLOC) in copy_elided_sections()
1507 &sec->shdr), in copy_elided_sections()
1542 GElf_Shdr *shdr = gelf_getshdr (sec->outscn, &shdr_mem); in copy_elided_sections() local
1543 ELF_CHECK (shdr != NULL, _("cannot get section header: %s")); in copy_elided_sections()
1553 shdr_mem.sh_addr = sec->shdr.sh_addr; in copy_elided_sections()
1555 shdr_mem.sh_type = sec->shdr.sh_type; in copy_elided_sections()
1556 shdr_mem.sh_size = sec->shdr.sh_size; in copy_elided_sections()
1557 shdr_mem.sh_info = sec->shdr.sh_info; in copy_elided_sections()
1558 shdr_mem.sh_link = sec->shdr.sh_link; in copy_elided_sections()
1562 if ((sec->shdr.sh_type == SHT_REL || sec->shdr.sh_type == SHT_RELA) in copy_elided_sections()
1563 && sec->shdr.sh_flags != shdr_mem.sh_flags in copy_elided_sections()
1564 && (sec->shdr.sh_flags & SHF_INFO_LINK) != 0) in copy_elided_sections()
1567 if (sec->shdr.sh_link != SHN_UNDEF) in copy_elided_sections()
1568 shdr_mem.sh_link = ndx_section[sec->shdr.sh_link - 1]; in copy_elided_sections()
1569 if (SH_INFO_LINK_P (&sec->shdr) && sec->shdr.sh_info != 0) in copy_elided_sections()
1570 shdr_mem.sh_info = ndx_section[sec->shdr.sh_info - 1]; in copy_elided_sections()
1585 shdr_mem.sh_offset = sec->shdr.sh_offset; in copy_elided_sections()
1653 : (stripped_symtab->shdr.sh_size in copy_elided_sections()
1654 / stripped_symtab->shdr.sh_entsize)); in copy_elided_sections()
1657 GElf_Shdr *shdr = gelf_getshdr (unstripped_symtab, &shdr_mem); in copy_elided_sections() local
1658 ELF_CHECK (shdr != NULL, _("cannot get section header: %s")); in copy_elided_sections()
1659 const size_t unstripped_nsym = shdr->sh_size / shdr->sh_entsize; in copy_elided_sections()
1670 elf_getscn (stripped, stripped_symtab->shdr.sh_link), in copy_elided_sections()
1674 Elf_Scn *unstripped_strtab = elf_getscn (unstripped, shdr->sh_link); in copy_elided_sections()
1788 shdr->sh_name = ebl_strtaboffset (unstripped_strent[i + 1]); in copy_elided_sections()
1795 shdr = gelf_getshdr (unstripped_symtab, &shdr_mem); in copy_elided_sections()
1796 ELF_CHECK (shdr != NULL, _("cannot get section header: %s")); in copy_elided_sections()
1798 shdr->sh_size = symdata->d_size = (1 + nsym) * shdr->sh_entsize; in copy_elided_sections()
1807 shdr->sh_info = 1; in copy_elided_sections()
1823 assert (shdr->sh_info == 1 + i); in copy_elided_sections()
1824 shdr->sh_info = 1 + i + 1; in copy_elided_sections()
1833 update_shdr (unstripped_symtab, shdr); in copy_elided_sections()
1842 if (sec->outscn != NULL && sec->shdr.sh_link == old_sh_link) in copy_elided_sections()
1843 adjust_relocs (sec->outscn, sec->scn, &sec->shdr, in copy_elided_sections()
1844 symndx_map, shdr); in copy_elided_sections()
1848 adjust_all_relocs (unstripped, unstripped_symtab, shdr, in copy_elided_sections()
1890 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); in copy_elided_sections() local
1891 ELF_CHECK (shdr != NULL, _("cannot get section header: %s")); in copy_elided_sections()
1903 && (shdr->sh_type == SHT_REL || shdr->sh_type == SHT_RELA)) in copy_elided_sections()
1906 GElf_Off align = shdr->sh_addralign ?: 1; in copy_elided_sections()
1908 shdr->sh_offset = offset; in copy_elided_sections()
1909 if (shdr->sh_type != SHT_NOBITS) in copy_elided_sections()
1910 offset += shdr->sh_size; in copy_elided_sections()
1912 update_shdr (scn, shdr); in copy_elided_sections()