Lines Matching refs:shdr
322 section_can_shrink (const GElf_Shdr *shdr)
324 switch (shdr->sh_type)
353 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (elf, i), &shdr_mem);
354 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
362 sym->st_value = shdr->sh_addr;
394 adjust_relocs (Elf_Scn *outscn, Elf_Scn *inscn, const GElf_Shdr *shdr,
406 switch (shdr->sh_type)
409 for (size_t i = 0; i < shdr->sh_size / shdr->sh_entsize; ++i)
420 for (size_t i = 0; i < shdr->sh_size / shdr->sh_entsize; ++i)
447 const size_t onent = shdr->sh_size / shdr->sh_entsize;
448 assert (data->d_size == shdr->sh_size);
478 switch (shdr->sh_entsize)
501 const size_t onent = shdr->sh_size / shdr->sh_entsize;
517 data->d_size = nent * shdr->sh_entsize;
541 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
542 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
543 if (shdr->sh_type != SHT_NOBITS && shdr->sh_link == new_sh_link)
544 adjust_relocs (scn, scn, shdr, map, symshdr);
558 GElf_Shdr *shdr = gelf_getshdr (symscn, &shdr_mem);
559 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
561 const size_t nsym = shdr->sh_size / shdr->sh_entsize;
564 shdr->sh_info += added;
565 shdr->sh_size += added * shdr->sh_entsize;
566 update_shdr (symscn, shdr);
571 symdata->d_size = shdr->sh_size;
623 adjust_all_relocs (elf, symscn, shdr, symndx_map);
655 GElf_Shdr shdr;
665 if (s1->shdr.sh_addr < s2->shdr.sh_addr)
667 if (s1->shdr.sh_addr > s2->shdr.sh_addr)
696 if ((s1->shdr.sh_flags ^ s2->shdr.sh_flags) & SHF_ALLOC)
697 return (s1->shdr.sh_flags & SHF_ALLOC) ? -1 : 1;
699 return ((s1->shdr.sh_flags & SHF_ALLOC)
701 : compare_unalloc_sections (&s1->shdr, &s2->shdr,
792 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (outelf, s->shndx),
794 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
795 s->value = shdr->sh_addr;
798 && s->value < split_bss->shdr.sh_addr
799 && s->value >= split_bss[-1].shdr.sh_addr
873 const GElf_Shdr *shdr, const char *name)
875 return (sections[i].shdr.sh_flags == shdr->sh_flags
876 && (sections[i].shdr.sh_size == shdr->sh_size
877 || (sections[i].shdr.sh_size < shdr->sh_size
878 && section_can_shrink (§ions[i].shdr)))
884 find_alloc_section (const GElf_Shdr *shdr, GElf_Addr bias, const char *name,
887 const GElf_Addr addr = shdr->sh_addr + bias;
892 if (addr < sections[i].shdr.sh_addr)
894 else if (addr > sections[i].shdr.sh_addr)
900 while (i > 0 && sections[i - 1].shdr.sh_addr == addr)
902 for (; i < nalloc && sections[i].shdr.sh_addr == addr;
904 if (sections_match (sections, i, shdr, name))
913 get_section_name (size_t ndx, const GElf_Shdr *shdr, const Elf_Data *shstrtab)
915 if (shdr->sh_name >= shstrtab->d_size)
918 return shstrtab->d_buf + shdr->sh_name;
941 if (sec->shdr.sh_type == SHT_PROGBITS
942 && !(sec->shdr.sh_flags & SHF_ALLOC)
1004 } shdr;
1005 dst.d_buf = &shdr;
1006 dst.d_size = sizeof shdr;
1017 #define COPY(field) sec->shdr.field = shdr.s32[i].field
1031 sec->shdr = shdr.s64[i];
1032 if (sec->shdr.sh_flags & SHF_ALLOC)
1034 sec->shdr.sh_addr += bias;
1035 sec->name = get_section_name (i + 1, &sec->shdr, main_shstrtab);
1061 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
1062 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1064 if (!(shdr->sh_flags & SHF_ALLOC))
1067 const char *name = get_section_name (elf_ndxscn (scn), shdr,
1072 struct section *sec = find_alloc_section (shdr, 0, name,
1084 for (size_t i = 0; shdr != NULL && i < nalloc; ++i)
1086 shdr = NULL;
1087 check_match (shdr == NULL, scn, name);
1108 (2 * sec->shdr.field == 3 * undo_sec->shdr.field)
1110 && sec->shdr.sh_name == undo_sec->shdr.sh_name
1111 && sec->shdr.sh_flags == undo_sec->shdr.sh_flags
1112 && sec->shdr.sh_addralign == undo_sec->shdr.sh_addralign
1113 && (((sec->shdr.sh_type == undo_sec->shdr.sh_type
1114 && sec->shdr.sh_entsize == undo_sec->shdr.sh_entsize
1115 && (sec->shdr.sh_size == undo_sec->shdr.sh_size
1116 || (sec->shdr.sh_size > undo_sec->shdr.sh_size
1119 || (sec->shdr.sh_size == undo_sec->shdr.sh_size
1120 && ((sec->shdr.sh_entsize == undo_sec->shdr.sh_entsize
1121 && undo_sec->shdr.sh_type == SHT_NOBITS)
1122 || undo_sec->shdr.sh_type == SHT_PROGBITS)
1124 || (sec->shdr.sh_type == SHT_RELA
1125 && undo_sec->shdr.sh_type == SHT_REL
1127 || (sec->shdr.sh_entsize == undo_sec->shdr.sh_entsize
1128 && (sec->shdr.sh_type == undo_sec->shdr.sh_type
1129 || (sec->shdr.sh_type == SHT_PROGBITS
1130 && undo_sec->shdr.sh_type == SHT_NOBITS))
1131 && sec->shdr.sh_size < undo_sec->shdr.sh_size
1187 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
1188 const char *name = get_section_name (i + 1, shdr, shstrtab);
1209 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
1210 shdr->sh_name = ebl_strtaboffset (unstripped_strent[i]);
1212 shdr->sh_size = strtab_data->d_size;
1213 update_shdr (scn, shdr);
1251 GElf_Shdr *shdr = gelf_getshdr (scn, §ions[i].shdr);
1252 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1254 shdr->sh_name);
1270 while (nalloc > 0 && !(sections[nalloc - 1].shdr.sh_flags & SHF_ALLOC))
1273 if (sections[nalloc].shdr.sh_type == SHT_SYMTAB)
1278 inline struct section *find_unalloc_section (const GElf_Shdr *shdr,
1286 int cmp = compare_unalloc_sections (shdr, &sec->shdr,
1311 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
1312 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1314 if (shdr->sh_type == SHT_SYMTAB)
1324 const char *name = get_section_name (ndx, shdr, shstrtab);
1327 if (shdr->sh_flags & SHF_ALLOC)
1332 sec = find_alloc_section (shdr, bias, name, sections, nalloc);
1344 if (likely (sections_match (sections, alloc_avail, shdr, name)))
1348 if (sections_match (sections, i, shdr, name))
1358 sec = find_unalloc_section (shdr, name);
1364 if (shdr->sh_type != SHT_NOBITS)
1428 && secndx == stripped_symtab->shdr.sh_link)
1432 GElf_Shdr *shdr = gelf_getshdr (unstripped_symtab, &shdr_mem);
1433 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1434 ndx_section[secndx - 1] = shdr->sh_link;
1438 if (!(sec->shdr.sh_flags & SHF_ALLOC)
1450 &sec->shdr),
1485 GElf_Shdr *shdr = gelf_getshdr (sec->outscn, &shdr_mem);
1486 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1491 is still zero in the corresponding shdr. The relocated
1496 shdr_mem.sh_addr = sec->shdr.sh_addr;
1498 shdr_mem.sh_type = sec->shdr.sh_type;
1499 shdr_mem.sh_size = sec->shdr.sh_size;
1500 shdr_mem.sh_info = sec->shdr.sh_info;
1501 shdr_mem.sh_link = sec->shdr.sh_link;
1502 if (sec->shdr.sh_link != SHN_UNDEF)
1503 shdr_mem.sh_link = ndx_section[sec->shdr.sh_link - 1];
1505 shdr_mem.sh_info = ndx_section[sec->shdr.sh_info - 1];
1520 shdr_mem.sh_offset = sec->shdr.sh_offset;
1588 : (stripped_symtab->shdr.sh_size
1589 / stripped_symtab->shdr.sh_entsize));
1592 GElf_Shdr *shdr = gelf_getshdr (unstripped_symtab, &shdr_mem);
1593 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1594 const size_t unstripped_nsym = shdr->sh_size / shdr->sh_entsize;
1605 elf_getscn (stripped, stripped_symtab->shdr.sh_link),
1609 Elf_Scn *unstripped_strtab = elf_getscn (unstripped, shdr->sh_link);
1690 shdr->sh_size = symdata->d_size = (1 + nsym) * shdr->sh_entsize;
1698 shdr->sh_info = 1;
1714 assert (shdr->sh_info == 1 + i);
1715 shdr->sh_info = 1 + i + 1;
1724 update_shdr (unstripped_symtab, shdr);
1733 if (sec->outscn != NULL && sec->shdr.sh_link == old_sh_link)
1734 adjust_relocs (sec->outscn, sec->scn, &sec->shdr,
1735 symndx_map, shdr);
1739 adjust_all_relocs (unstripped, unstripped_symtab, shdr,
1781 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
1782 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1794 && (shdr->sh_type == SHT_REL || shdr->sh_type == SHT_RELA))
1797 GElf_Off align = shdr->sh_addralign ?: 1;
1799 shdr->sh_offset = offset;
1800 if (shdr->sh_type != SHT_NOBITS)
1801 offset += shdr->sh_size;
1803 update_shdr (scn, shdr);