Lines Matching defs: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;
388 adjust_relocs (Elf_Scn *outscn, Elf_Scn *inscn, const GElf_Shdr *shdr,
400 switch (shdr->sh_type)
403 for (size_t i = 0; i < shdr->sh_size / shdr->sh_entsize; ++i)
414 for (size_t i = 0; i < shdr->sh_size / shdr->sh_entsize; ++i)
442 const size_t onent = shdr->sh_size / shdr->sh_entsize;
443 assert (data->d_size == shdr->sh_size);
473 switch (shdr->sh_entsize)
496 const size_t onent = shdr->sh_size / shdr->sh_entsize;
512 data->d_size = nent * shdr->sh_entsize;
536 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
537 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
538 if (shdr->sh_type != SHT_NOBITS && shdr->sh_link == new_sh_link)
539 adjust_relocs (scn, scn, shdr, map, symshdr);
553 GElf_Shdr *shdr = gelf_getshdr (symscn, &shdr_mem);
554 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
556 const size_t nsym = shdr->sh_size / shdr->sh_entsize;
559 shdr->sh_info += added;
560 shdr->sh_size += added * shdr->sh_entsize;
562 ELF_CHECK (gelf_update_shdr (symscn, shdr),
568 symdata->d_size = shdr->sh_size;
620 adjust_all_relocs (elf, symscn, shdr, symndx_map);
652 GElf_Shdr shdr;
662 if (s1->shdr.sh_addr < s2->shdr.sh_addr)
664 if (s1->shdr.sh_addr > s2->shdr.sh_addr)
693 if ((s1->shdr.sh_flags ^ s2->shdr.sh_flags) & SHF_ALLOC)
694 return (s1->shdr.sh_flags & SHF_ALLOC) ? -1 : 1;
696 return ((s1->shdr.sh_flags & SHF_ALLOC)
698 : compare_unalloc_sections (&s1->shdr, &s2->shdr,
789 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (outelf, s->shndx),
791 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
792 s->value = shdr->sh_addr;
795 && s->value < split_bss->shdr.sh_addr
796 && s->value >= split_bss[-1].shdr.sh_addr
870 const GElf_Shdr *shdr, const char *name)
872 return (sections[i].shdr.sh_flags == shdr->sh_flags
873 && (sections[i].shdr.sh_size == shdr->sh_size
874 || (sections[i].shdr.sh_size < shdr->sh_size
875 && section_can_shrink (§ions[i].shdr)))
881 find_alloc_section (const GElf_Shdr *shdr, GElf_Addr bias, const char *name,
884 const GElf_Addr addr = shdr->sh_addr + bias;
889 if (addr < sections[i].shdr.sh_addr)
891 else if (addr > sections[i].shdr.sh_addr)
897 while (i > 0 && sections[i - 1].shdr.sh_addr == addr)
899 for (; i < nalloc && sections[i].shdr.sh_addr == addr;
901 if (sections_match (sections, i, shdr, name))
910 get_section_name (size_t ndx, const GElf_Shdr *shdr, const Elf_Data *shstrtab)
912 if (shdr->sh_name >= shstrtab->d_size)
915 return shstrtab->d_buf + shdr->sh_name;
938 if (sec->shdr.sh_type == SHT_PROGBITS
939 && !(sec->shdr.sh_flags & SHF_ALLOC)
1001 } shdr;
1002 dst.d_buf = &shdr;
1003 dst.d_size = sizeof shdr;
1014 #define COPY(field) sec->shdr.field = shdr.s32[i].field
1028 sec->shdr = shdr.s64[i];
1029 if (sec->shdr.sh_flags & SHF_ALLOC)
1031 sec->shdr.sh_addr += bias;
1032 sec->name = get_section_name (i + 1, &sec->shdr, main_shstrtab);
1058 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
1059 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1061 if (!(shdr->sh_flags & SHF_ALLOC))
1064 const char *name = get_section_name (elf_ndxscn (scn), shdr,
1069 struct section *sec = find_alloc_section (shdr, 0, name,
1081 for (size_t i = 0; shdr != NULL && i < nalloc; ++i)
1083 shdr = NULL;
1084 check_match (shdr == NULL, scn, name);
1105 (2 * sec->shdr.field == 3 * undo_sec->shdr.field)
1107 && sec->shdr.sh_name == undo_sec->shdr.sh_name
1108 && sec->shdr.sh_flags == undo_sec->shdr.sh_flags
1109 && sec->shdr.sh_addralign == undo_sec->shdr.sh_addralign
1110 && (((sec->shdr.sh_type == undo_sec->shdr.sh_type
1111 && sec->shdr.sh_entsize == undo_sec->shdr.sh_entsize
1112 && (sec->shdr.sh_size == undo_sec->shdr.sh_size
1113 || (sec->shdr.sh_size > undo_sec->shdr.sh_size
1116 || (sec->shdr.sh_size == undo_sec->shdr.sh_size
1117 && ((sec->shdr.sh_entsize == undo_sec->shdr.sh_entsize
1118 && undo_sec->shdr.sh_type == SHT_NOBITS)
1119 || undo_sec->shdr.sh_type == SHT_PROGBITS)
1121 || (sec->shdr.sh_type == SHT_RELA
1122 && undo_sec->shdr.sh_type == SHT_REL
1124 || (sec->shdr.sh_entsize == undo_sec->shdr.sh_entsize
1125 && (sec->shdr.sh_type == undo_sec->shdr.sh_type
1126 || (sec->shdr.sh_type == SHT_PROGBITS
1127 && undo_sec->shdr.sh_type == SHT_NOBITS))
1128 && sec->shdr.sh_size < undo_sec->shdr.sh_size
1184 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
1185 const char *name = get_section_name (i + 1, shdr, shstrtab);
1206 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
1207 shdr->sh_name = ebl_strtaboffset (unstripped_strent[i]);
1209 shdr->sh_size = strtab_data->d_size;
1210 ELF_CHECK (gelf_update_shdr (scn, shdr),
1245 GElf_Shdr *shdr = gelf_getshdr (scn, §ions[i].shdr);
1246 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1248 shdr->sh_name);
1264 while (nalloc > 0 && !(sections[nalloc - 1].shdr.sh_flags & SHF_ALLOC))
1267 if (sections[nalloc].shdr.sh_type == SHT_SYMTAB)
1272 inline struct section *find_unalloc_section (const GElf_Shdr *shdr,
1280 int cmp = compare_unalloc_sections (shdr, &sec->shdr,
1306 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
1307 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1309 if (shdr->sh_type == SHT_SYMTAB)
1312 unstripped_strtab_ndx = shdr->sh_link;
1320 const char *name = get_section_name (ndx, shdr, shstrtab);
1323 if (shdr->sh_flags & SHF_ALLOC)
1328 sec = find_alloc_section (shdr, bias, name, sections, nalloc);
1340 if (likely (sections_match (sections, alloc_avail, shdr, name)))
1344 if (sections_match (sections, i, shdr, name))
1354 sec = find_unalloc_section (shdr, name);
1360 if (shdr->sh_type != SHT_NOBITS)
1424 && secndx == stripped_symtab->shdr.sh_link)
1428 GElf_Shdr *shdr = gelf_getshdr (unstripped_symtab, &shdr_mem);
1429 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1430 ndx_section[secndx - 1] = shdr->sh_link;
1434 if (!(sec->shdr.sh_flags & SHF_ALLOC)
1446 &sec->shdr),
1481 GElf_Shdr *shdr = gelf_getshdr (sec->outscn, &shdr_mem);
1482 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1487 is still zero in the corresponding shdr. The relocated
1492 shdr_mem.sh_addr = sec->shdr.sh_addr;
1494 shdr_mem.sh_type = sec->shdr.sh_type;
1495 shdr_mem.sh_size = sec->shdr.sh_size;
1496 shdr_mem.sh_info = sec->shdr.sh_info;
1497 shdr_mem.sh_link = sec->shdr.sh_link;
1498 if (sec->shdr.sh_link != SHN_UNDEF)
1499 shdr_mem.sh_link = ndx_section[sec->shdr.sh_link - 1];
1501 shdr_mem.sh_info = ndx_section[sec->shdr.sh_info - 1];
1516 shdr_mem.sh_offset = sec->shdr.sh_offset;
1585 : (stripped_symtab->shdr.sh_size
1586 / stripped_symtab->shdr.sh_entsize));
1589 GElf_Shdr *shdr = gelf_getshdr (unstripped_symtab, &shdr_mem);
1590 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1591 const size_t unstripped_nsym = shdr->sh_size / shdr->sh_entsize;
1602 elf_getscn (stripped, stripped_symtab->shdr.sh_link),
1606 Elf_Scn *unstripped_strtab = elf_getscn (unstripped, shdr->sh_link);
1687 shdr->sh_size = symdata->d_size = (1 + nsym) * shdr->sh_entsize;
1695 shdr->sh_info = 1;
1711 assert (shdr->sh_info == 1 + i);
1712 shdr->sh_info = 1 + i + 1;
1721 ELF_CHECK (gelf_update_shdr (unstripped_symtab, shdr),
1731 if (sec->outscn != NULL && sec->shdr.sh_link == old_sh_link)
1732 adjust_relocs (sec->outscn, sec->scn, &sec->shdr,
1733 symndx_map, shdr);
1737 adjust_all_relocs (unstripped, unstripped_symtab, shdr,
1779 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
1780 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1783 && (shdr->sh_type == SHT_REL || shdr->sh_type == SHT_RELA))
1786 GElf_Off align = shdr->sh_addralign ?: 1;
1788 shdr->sh_offset = offset;
1789 if (shdr->sh_type != SHT_NOBITS)
1790 offset += shdr->sh_size;
1792 ELF_CHECK (gelf_update_shdr (scn, shdr),