Home | History | Annotate | Download | only in src

Lines Matching refs:shdr

364 section_can_shrink (const GElf_Shdr *shdr)
366 switch (shdr->sh_type)
395 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (elf, i), &shdr_mem);
396 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
404 sym->st_value = shdr->sh_addr;
436 adjust_relocs (Elf_Scn *outscn, Elf_Scn *inscn, const GElf_Shdr *shdr,
448 switch (shdr->sh_type)
451 if (shdr->sh_entsize == 0)
454 for (size_t i = 0; i < shdr->sh_size / shdr->sh_entsize; ++i)
465 if (shdr->sh_entsize == 0)
468 for (size_t i = 0; i < shdr->sh_size / shdr->sh_entsize; ++i)
494 if (shdr->sh_entsize == 0)
499 const size_t onent = shdr->sh_size / shdr->sh_entsize;
500 assert (data->d_size == shdr->sh_size);
531 switch (shdr->sh_entsize)
553 if (shdr->sh_entsize == 0)
559 const size_t onent = shdr->sh_size / shdr->sh_entsize;
576 data->d_size = nent * shdr->sh_entsize;
600 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
601 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
605 if (shdr->sh_type != SHT_NOBITS && shdr->sh_type != SHT_GROUP
606 && shdr->sh_link == new_sh_link)
607 adjust_relocs (scn, scn, shdr, map, symshdr);
621 GElf_Shdr *shdr = gelf_getshdr (symscn, &shdr_mem);
622 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
623 if (shdr->sh_entsize == 0)
626 const size_t nsym = shdr->sh_size / shdr->sh_entsize;
629 shdr->sh_info += added;
630 shdr->sh_size += added * shdr->sh_entsize;
631 update_shdr (symscn, shdr);
636 symdata->d_size = shdr->sh_size;
689 adjust_all_relocs (elf, symscn, shdr, symndx_map);
722 GElf_Shdr shdr;
732 if (s1->shdr.sh_addr < s2->shdr.sh_addr)
734 if (s1->shdr.sh_addr > s2->shdr.sh_addr)
774 if ((s1->shdr.sh_flags ^ s2->shdr.sh_flags) & SHF_ALLOC)
775 return (s1->shdr.sh_flags & SHF_ALLOC) ? -1 : 1;
777 return ((s1->shdr.sh_flags & SHF_ALLOC)
779 : compare_unalloc_sections (&s1->shdr, &s2->shdr,
871 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (outelf, s->shndx),
873 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
874 s->value = shdr->sh_addr;
877 && s->value < split_bss->shdr.sh_addr
878 && s->value >= split_bss[-1].shdr.sh_addr
967 const GElf_Shdr *shdr, const char *name)
969 return (sections_flags_match (sections[i].shdr.sh_flags, shdr->sh_flags,
970 sections[i].shdr.sh_type)
971 && (sections[i].shdr.sh_size == shdr->sh_size
972 || (sections[i].shdr.sh_size < shdr->sh_size
973 && section_can_shrink (&sections[i].shdr)))
979 find_alloc_section (const GElf_Shdr *shdr, GElf_Addr bias, const char *name,
982 const GElf_Addr addr = shdr->sh_addr + bias;
987 if (addr < sections[i].shdr.sh_addr)
989 else if (addr > sections[i].shdr.sh_addr)
995 while (i > 0 && sections[i - 1].shdr.sh_addr == addr)
997 for (; i < nalloc && sections[i].shdr.sh_addr == addr;
999 if (sections_match (sections, i, shdr, name))
1008 get_section_name (size_t ndx, const GElf_Shdr *shdr, const Elf_Data *shstrtab)
1010 if (shdr->sh_name >= shstrtab->d_size)
1013 return shstrtab->d_buf + shdr->sh_name;
1019 get_group_sig (Elf *elf, GElf_Shdr *shdr)
1021 if (shdr->sh_type != SHT_GROUP)
1024 Elf_Scn *symscn = elf_getscn (elf, shdr->sh_link);
1032 error (EXIT_FAILURE, 0, _("couldn't get shdr for group section: %s"),
1041 GElf_Sym *sym = gelf_getsym (symdata, shdr->sh_info, &sym_mem);
1070 if (sec->shdr.sh_type == SHT_PROGBITS
1071 && !(sec->shdr.sh_flags & SHF_ALLOC)
1142 void *shdr = xmalloc (shdr_bytes);
1143 dst.d_buf = shdr;
1153 Elf32_Shdr (*s32)[shnum] = shdr;
1154 Elf64_Shdr (*s64)[shnum] = shdr;
1157 #define COPY(field) sec->shdr.field = (*s32)[i].field
1171 sec->shdr = (*s64)[i];
1172 if (sec->shdr.sh_flags & SHF_ALLOC)
1174 sec->shdr.sh_addr += bias;
1175 sec->name = get_section_name (i + 1, &sec->shdr, main_shstrtab);
1179 sec->sig = get_group_sig (main, &sec->shdr);
1185 free (shdr);
1203 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
1204 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1206 if (!(shdr->sh_flags & SHF_ALLOC))
1209 const char *name = get_section_name (elf_ndxscn (scn), shdr,
1214 struct section *sec = find_alloc_section (shdr, 0, name,
1226 for (size_t i = 0; shdr != NULL && i < nalloc; ++i)
1228 shdr = NULL;
1229 check_match (shdr == NULL, scn, name);
1250 (2 * sec->shdr.field == 3 * undo_sec->shdr.field)
1252 && sec->shdr.sh_name == undo_sec->shdr.sh_name
1253 && sec->shdr.sh_flags == undo_sec->shdr.sh_flags
1254 && sec->shdr.sh_addralign == undo_sec->shdr.sh_addralign
1255 && (((sec->shdr.sh_type == undo_sec->shdr.sh_type
1256 && sec->shdr.sh_entsize == undo_sec->shdr.sh_entsize
1257 && (sec->shdr.sh_size == undo_sec->shdr.sh_size
1258 || (sec->shdr.sh_size > undo_sec->shdr.sh_size
1261 || (sec->shdr.sh_size == undo_sec->shdr.sh_size
1262 && ((sec->shdr.sh_entsize == undo_sec->shdr.sh_entsize
1263 && undo_sec->shdr.sh_type == SHT_NOBITS)
1264 || undo_sec->shdr.sh_type == SHT_PROGBITS)
1266 || (sec->shdr.sh_type == SHT_RELA
1267 && undo_sec->shdr.sh_type == SHT_REL
1269 || (sec->shdr.sh_entsize == undo_sec->shdr.sh_entsize
1270 && (sec->shdr.sh_type == undo_sec->shdr.sh_type
1271 || (sec->shdr.sh_type == SHT_PROGBITS
1272 && undo_sec->shdr.sh_type == SHT_NOBITS))
1273 && sec->shdr.sh_size <= undo_sec->shdr.sh_size
1276 && (sec->shdr.sh_size == undo_sec->shdr.sh_size
1330 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
1331 const char *name = get_section_name (i + 1, shdr, shstrtab);
1353 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
1354 shdr->sh_name = dwelf_strent_off (unstripped_strent[i]);
1356 shdr->sh_size = strtab_data->d_size;
1357 update_shdr (scn, shdr);
1395 GElf_Shdr *shdr = gelf_getshdr (scn, &sections[i].shdr);
1396 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1398 shdr->sh_name);
1405 sections[i].sig = get_group_sig (stripped, shdr);
1415 while (nalloc > 0 && !(sections[nalloc - 1].shdr.sh_flags & SHF_ALLOC))
1418 if (sections[nalloc].shdr.sh_type == SHT_SYMTAB)
1423 inline struct section *find_unalloc_section (const GElf_Shdr *shdr,
1432 int cmp = compare_unalloc_sections (shdr, &sec->shdr,
1459 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
1460 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1462 if (shdr->sh_type == SHT_SYMTAB)
1465 unstripped_strndx = shdr->sh_link;
1473 const char *name = get_section_name (ndx, shdr, shstrtab);
1476 if (shdr->sh_flags & SHF_ALLOC)
1481 sec = find_alloc_section (shdr, bias, name, sections, nalloc);
1493 if (likely (sections_match (sections, alloc_avail, shdr, name)))
1497 if (sections_match (sections, i, shdr, name))
1507 sec = find_unalloc_section (shdr, name,
1508 get_group_sig (unstripped, shdr));
1514 if (shdr->sh_type != SHT_NOBITS)
1578 && secndx == stripped_symtab->shdr.sh_link
1586 if (!(sec->shdr.sh_flags & SHF_ALLOC)
1598 &sec->shdr),
1633 GElf_Shdr *shdr = gelf_getshdr (sec->outscn, &shdr_mem);
1634 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1639 is still zero in the corresponding shdr. The relocated
1644 shdr_mem.sh_addr = sec->shdr.sh_addr;
1646 shdr_mem.sh_type = sec->shdr.sh_type;
1647 shdr_mem.sh_size = sec->shdr.sh_size;
1648 shdr_mem.sh_info = sec->shdr.sh_info;
1649 shdr_mem.sh_link = sec->shdr.sh_link;
1653 if ((sec->shdr.sh_type == SHT_REL || sec->shdr.sh_type == SHT_RELA)
1654 && sec->shdr.sh_flags != shdr_mem.sh_flags
1655 && (sec->shdr.sh_flags & SHF_INFO_LINK) != 0)
1658 if (sec->shdr.sh_link != SHN_UNDEF)
1659 shdr_mem.sh_link = ndx_section[sec->shdr.sh_link - 1];
1660 if (SH_INFO_LINK_P (&sec->shdr) && sec->shdr.sh_info != 0)
1661 shdr_mem.sh_info = ndx_section[sec->shdr.sh_info - 1];
1676 shdr_mem.sh_offset = sec->shdr.sh_offset;
1761 : (stripped_symtab->shdr.sh_size
1762 / (stripped_symtab->shdr.sh_entsize == 0
1764 : stripped_symtab->shdr.sh_entsize)));
1767 GElf_Shdr *shdr = gelf_getshdr (unstripped_symtab, &shdr_mem);
1768 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1769 if (shdr->sh_entsize == 0)
1772 const size_t unstripped_nsym = shdr->sh_size / shdr->sh_entsize;
1783 elf_getscn (stripped, stripped_symtab->shdr.sh_link),
1787 Elf_Scn *unstripped_strtab = elf_getscn (unstripped, shdr->sh_link);
1903 shdr->sh_name = dwelf_strent_off (unstripped_strent[i]);
1908 /* Now update the symtab shdr. Reload symtab shdr because sh_name
1910 shdr = gelf_getshdr (unstripped_symtab, &shdr_mem);
1911 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1913 shdr->sh_size = symdata->d_size = (1 + nsym) * shdr->sh_entsize;
1922 shdr->sh_info = 1;
1938 assert (shdr->sh_info == 1 + i);
1939 shdr->sh_info = 1 + i + 1;
1948 update_shdr (unstripped_symtab, shdr);
1957 if (sec->outscn != NULL && sec->shdr.sh_link == old_sh_link)
1958 adjust_relocs (sec->outscn, sec->scn, &sec->shdr,
1959 symndx_map, shdr);
1963 adjust_all_relocs (unstripped, unstripped_symtab, shdr,
2005 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
2006 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
2018 && (shdr->sh_type == SHT_REL || shdr->sh_type == SHT_RELA))
2021 GElf_Off align = shdr->sh_addralign ?: 1;
2023 shdr->sh_offset = offset;
2024 if (shdr->sh_type != SHT_NOBITS)
2025 offset += shdr->sh_size;
2027 update_shdr (scn, shdr);