Lines Matching refs:shdr
365 section_can_shrink (const GElf_Shdr *shdr)
367 switch (shdr->sh_type)
396 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (elf, i), &shdr_mem);
397 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
405 sym->st_value = shdr->sh_addr;
450 adjust_relocs (Elf_Scn *outscn, Elf_Scn *inscn, const GElf_Shdr *shdr,
455 switch (shdr->sh_type)
458 if (shdr->sh_entsize == 0)
461 for (size_t i = 0; i < shdr->sh_size / shdr->sh_entsize; ++i)
473 if (shdr->sh_entsize == 0)
476 for (size_t i = 0; i < shdr->sh_size / shdr->sh_entsize; ++i)
503 if (shdr->sh_entsize == 0)
508 const size_t onent = shdr->sh_size / shdr->sh_entsize;
509 if (data->d_size != shdr->sh_size)
542 switch (shdr->sh_entsize)
564 if (shdr->sh_entsize == 0)
569 const size_t onent = shdr->sh_size / shdr->sh_entsize;
610 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
611 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
615 if (shdr->sh_type != SHT_NOBITS && shdr->sh_type != SHT_GROUP
616 && shdr->sh_link == new_sh_link)
617 adjust_relocs (scn, scn, shdr, map, map_size, symshdr);
631 GElf_Shdr *shdr = gelf_getshdr (symscn, &shdr_mem);
632 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
633 if (shdr->sh_entsize == 0)
636 const size_t nsym = shdr->sh_size / shdr->sh_entsize;
639 shdr->sh_info += added;
640 shdr->sh_size += added * shdr->sh_entsize;
641 update_shdr (symscn, shdr);
646 symdata->d_size = shdr->sh_size;
701 adjust_all_relocs (elf, symscn, shdr, symndx_map, nsym - 1);
734 GElf_Shdr shdr;
744 if (s1->shdr.sh_addr < s2->shdr.sh_addr)
746 if (s1->shdr.sh_addr > s2->shdr.sh_addr)
786 if ((s1->shdr.sh_flags ^ s2->shdr.sh_flags) & SHF_ALLOC)
787 return (s1->shdr.sh_flags & SHF_ALLOC) ? -1 : 1;
789 return ((s1->shdr.sh_flags & SHF_ALLOC)
791 : compare_unalloc_sections (&s1->shdr, &s2->shdr,
887 GElf_Shdr *shdr = gelf_getshdr (elf_getscn (outelf, s->shndx),
889 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
890 s->value = shdr->sh_addr;
893 && s->value < split_bss->shdr.sh_addr
894 && s->value >= split_bss[-1].shdr.sh_addr
983 const GElf_Shdr *shdr, const char *name)
985 return (sections_flags_match (sections[i].shdr.sh_flags, shdr->sh_flags,
986 sections[i].shdr.sh_type)
987 && (sections[i].shdr.sh_size == shdr->sh_size
988 || (sections[i].shdr.sh_size < shdr->sh_size
989 && section_can_shrink (§ions[i].shdr)))
995 find_alloc_section (const GElf_Shdr *shdr, GElf_Addr bias, const char *name,
998 const GElf_Addr addr = shdr->sh_addr + bias;
1003 if (addr < sections[i].shdr.sh_addr)
1005 else if (addr > sections[i].shdr.sh_addr)
1011 while (i > 0 && sections[i - 1].shdr.sh_addr == addr)
1013 for (; i < nalloc && sections[i].shdr.sh_addr == addr;
1015 if (sections_match (sections, i, shdr, name))
1024 get_section_name (size_t ndx, const GElf_Shdr *shdr, const Elf_Data *shstrtab)
1026 if (shdr->sh_name >= shstrtab->d_size)
1029 return shstrtab->d_buf + shdr->sh_name;
1035 get_group_sig (Elf *elf, GElf_Shdr *shdr)
1037 if (shdr->sh_type != SHT_GROUP)
1040 Elf_Scn *symscn = elf_getscn (elf, shdr->sh_link);
1048 error_exit (0, _("couldn't get shdr for group section: %s"),
1057 GElf_Sym *sym = gelf_getsym (symdata, shdr->sh_info, &sym_mem);
1100 if (sec->shdr.sh_type == SHT_PROGBITS
1101 && !(sec->shdr.sh_flags & SHF_ALLOC)
1172 void *shdr = xmalloc (shdr_bytes);
1173 dst.d_buf = shdr;
1183 Elf32_Shdr (*s32)[shnum] = shdr;
1184 Elf64_Shdr (*s64)[shnum] = shdr;
1187 #define COPY(field) sec->shdr.field = (*s32)[i].field
1201 sec->shdr = (*s64)[i];
1202 if (sec->shdr.sh_flags & SHF_ALLOC)
1204 sec->shdr.sh_addr += bias;
1205 sec->name = get_section_name (i + 1, &sec->shdr, main_shstrtab);
1209 sec->sig = get_group_sig (main, &sec->shdr);
1215 free (shdr);
1223 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
1224 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1226 if (!(shdr->sh_flags & SHF_ALLOC))
1229 const char *name = get_section_name (elf_ndxscn (scn), shdr,
1234 struct section *sec = find_alloc_section (shdr, 0, name,
1246 for (size_t i = 0; shdr != NULL && i < nalloc; ++i)
1248 shdr = NULL;
1249 fail |= check_match (shdr == NULL, scn, name);
1270 (2 * sec->shdr.field == 3 * undo_sec->shdr.field)
1272 && sec->shdr.sh_name == undo_sec->shdr.sh_name
1273 && sec->shdr.sh_flags == undo_sec->shdr.sh_flags
1274 && sec->shdr.sh_addralign == undo_sec->shdr.sh_addralign
1275 && (((sec->shdr.sh_type == undo_sec->shdr.sh_type
1276 && sec->shdr.sh_entsize == undo_sec->shdr.sh_entsize
1277 && (sec->shdr.sh_size == undo_sec->shdr.sh_size
1278 || (sec->shdr.sh_size > undo_sec->shdr.sh_size
1281 || (sec->shdr.sh_size == undo_sec->shdr.sh_size
1282 && ((sec->shdr.sh_entsize == undo_sec->shdr.sh_entsize
1283 && undo_sec->shdr.sh_type == SHT_NOBITS)
1284 || undo_sec->shdr.sh_type == SHT_PROGBITS)
1286 || (sec->shdr.sh_type == SHT_RELA
1287 && undo_sec->shdr.sh_type == SHT_REL
1289 || (sec->shdr.sh_entsize == undo_sec->shdr.sh_entsize
1290 && (sec->shdr.sh_type == undo_sec->shdr.sh_type
1291 || (sec->shdr.sh_type == SHT_PROGBITS
1292 && undo_sec->shdr.sh_type == SHT_NOBITS))
1293 && sec->shdr.sh_size <= undo_sec->shdr.sh_size
1296 && (sec->shdr.sh_size == undo_sec->shdr.sh_size
1350 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
1351 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1352 const char *name = get_section_name (i + 1, shdr, shstrtab);
1374 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
1375 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1376 shdr->sh_name = dwelf_strent_off (unstripped_strent[i]);
1378 shdr->sh_size = strtab_data->d_size;
1379 update_shdr (scn, shdr);
1430 GElf_Shdr *shdr = gelf_getshdr (scn, §ions[i].shdr);
1431 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1433 shdr->sh_name);
1440 sections[i].sig = get_group_sig (stripped, shdr);
1450 while (nalloc > 0 && !(sections[nalloc - 1].shdr.sh_flags & SHF_ALLOC))
1453 if (sections[nalloc].shdr.sh_type == SHT_SYMTAB)
1471 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
1472 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1474 if (shdr->sh_type == SHT_SYMTAB)
1477 unstripped_strndx = shdr->sh_link;
1485 const char *name = get_section_name (ndx, shdr, shstrtab);
1488 if (shdr->sh_flags & SHF_ALLOC)
1493 sec = find_alloc_section (shdr, bias, name, sections, nalloc);
1505 if (likely (sections_match (sections, alloc_avail, shdr, name)))
1509 if (sections_match (sections, i, shdr, name))
1519 const char *sig = get_group_sig (unstripped, shdr);
1525 int cmp = compare_unalloc_sections (shdr, §ion->shdr,
1544 if (shdr->sh_type != SHT_NOBITS)
1608 && secndx == stripped_symtab->shdr.sh_link
1616 if (!(sec->shdr.sh_flags & SHF_ALLOC)
1628 &sec->shdr),
1663 GElf_Shdr *shdr = gelf_getshdr (sec->outscn, &shdr_mem);
1664 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1669 is still zero in the corresponding shdr. The relocated
1674 shdr_mem.sh_addr = sec->shdr.sh_addr;
1676 shdr_mem.sh_type = sec->shdr.sh_type;
1677 shdr_mem.sh_size = sec->shdr.sh_size;
1678 shdr_mem.sh_info = sec->shdr.sh_info;
1679 shdr_mem.sh_link = sec->shdr.sh_link;
1683 if ((sec->shdr.sh_type == SHT_REL || sec->shdr.sh_type == SHT_RELA)
1684 && sec->shdr.sh_flags != shdr_mem.sh_flags
1685 && (sec->shdr.sh_flags & SHF_INFO_LINK) != 0)
1688 if (sec->shdr.sh_link != SHN_UNDEF)
1690 if (sec->shdr.sh_link > ndx_sec_num)
1693 elf_ndxscn (sec->scn), sec->shdr.sh_link);
1694 shdr_mem.sh_link = ndx_section[sec->shdr.sh_link - 1];
1696 if (SH_INFO_LINK_P (&sec->shdr) && sec->shdr.sh_info != 0)
1698 if (sec->shdr.sh_info > ndx_sec_num)
1701 elf_ndxscn (sec->scn), sec->shdr.sh_info);
1702 shdr_mem.sh_info = ndx_section[sec->shdr.sh_info - 1];
1718 if (max_off > 0 && sec->shdr.sh_offset > (Elf64_Off) max_off)
1721 elf_ndxscn (sec->scn), sec->shdr.sh_offset);
1723 shdr_mem.sh_offset = sec->shdr.sh_offset;
1808 : (stripped_symtab->shdr.sh_size
1809 / (stripped_symtab->shdr.sh_entsize == 0
1811 : stripped_symtab->shdr.sh_entsize)));
1814 GElf_Shdr *shdr = gelf_getshdr (unstripped_symtab, &shdr_mem);
1815 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1816 if (shdr->sh_entsize == 0)
1819 const size_t unstripped_nsym = shdr->sh_size / shdr->sh_entsize;
1830 elf_getscn (stripped, stripped_symtab->shdr.sh_link),
1834 Elf_Scn *unstripped_strtab = elf_getscn (unstripped, shdr->sh_link);
1950 shdr->sh_name = dwelf_strent_off (unstripped_strent[i]);
1955 /* Now update the symtab shdr. Reload symtab shdr because sh_name
1957 shdr = gelf_getshdr (unstripped_symtab, &shdr_mem);
1958 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
1960 shdr->sh_size = symdata->d_size = (1 + nsym) * shdr->sh_entsize;
1969 shdr->sh_info = 1;
1985 assert (shdr->sh_info == 1 + i);
1986 shdr->sh_info = 1 + i + 1;
1995 update_shdr (unstripped_symtab, shdr);
2004 if (sec->outscn != NULL && sec->shdr.sh_link == old_sh_link)
2005 adjust_relocs (sec->outscn, sec->scn, &sec->shdr,
2006 symndx_map, total_syms, shdr);
2010 adjust_all_relocs (unstripped, unstripped_symtab, shdr,
2056 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
2057 ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
2069 && (shdr->sh_type == SHT_REL || shdr->sh_type == SHT_RELA))
2072 GElf_Off align = shdr->sh_addralign ?: 1;
2074 shdr->sh_offset = offset;
2075 if (shdr->sh_type != SHT_NOBITS)
2076 offset += shdr->sh_size;
2078 update_shdr (scn, shdr);