Lines Matching refs:cnt
958 size_t cnt,
970 cnt), NULL);
1013 size_t cnt;
1130 for (cnt = 0; cnt < phnum; ++cnt)
1133 GElf_Phdr *phdr = gelf_getphdr (elf, cnt, &phdr_mem);
1135 || unlikely (gelf_update_phdr (newelf, cnt, phdr) == 0))
1173 for (cnt = 0; cnt < phnum; ++cnt)
1176 GElf_Phdr *phdr = gelf_getphdr (elf, cnt, &phdr_mem);
1178 || unlikely (gelf_update_phdr (debugelf, cnt, phdr) == 0))
1218 cnt = 1;
1223 elf_assert (elf_ndxscn (scn) == cnt);
1225 shdr_info[cnt].scn = scn;
1228 if (gelf_getshdr (scn, &shdr_info[cnt].shdr) == NULL)
1233 if ((shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) == 0)
1243 shdr_info[cnt].name = elf_strptr (elf, shstrndx,
1244 shdr_info[cnt].shdr.sh_name);
1245 if (shdr_info[cnt].name == NULL)
1253 if (section_name_matches (remove_secs, shdr_info[cnt].name))
1255 if ((shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) != 0)
1259 shdr_info[cnt].name);
1264 if (section_name_matches (keep_secs, shdr_info[cnt].name))
1268 shdr_info[cnt].name);
1275 shdr_info[cnt].idx = 1;
1278 shdr_info[cnt].old_sh_link = shdr_info[cnt].shdr.sh_link;
1279 if (shdr_info[cnt].old_sh_link >= shnum)
1289 || (shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) == 0)
1290 shdr_info[cnt].shdr.sh_offset = 0;
1294 if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX))
1296 elf_assert (shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0);
1297 shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx = cnt;
1299 else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GROUP))
1303 shdr_info[cnt].data = elf_getdata (shdr_info[cnt].scn, NULL);
1304 if (shdr_info[cnt].data == NULL
1305 || shdr_info[cnt].data->d_size < sizeof (Elf32_Word))
1309 Elf32_Word *grpref = (Elf32_Word *) shdr_info[cnt].data->d_buf;
1312 inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word);
1316 shdr_info[grpref[inner]].group_idx = cnt;
1324 shdr_info[cnt].idx = 0;
1326 shdr_info[cnt].group_cnt = inner - 1;
1328 else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GNU_versym))
1330 elf_assert (shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0);
1331 shdr_info[shdr_info[cnt].shdr.sh_link].version_idx = cnt;
1336 if ((shdr_info[cnt].shdr.sh_flags & SHF_GROUP) != 0)
1338 elf_assert (shdr_info[cnt].group_idx != 0);
1340 if (shdr_info[shdr_info[cnt].group_idx].idx == 0)
1348 shdr_info[cnt].group_idx = 0;
1353 ++cnt;
1367 for (cnt = 1; cnt < shnum; ++cnt)
1370 if (remove_shdrs ? !(shdr_info[cnt].shdr.sh_flags & SHF_ALLOC)
1371 : (ebl_section_strip_p (ebl, &shdr_info[cnt].shdr,
1372 shdr_info[cnt].name, remove_comment,
1374 || cnt == shstrndx
1375 || section_name_matches (remove_secs, shdr_info[cnt].name)))
1378 if (section_name_matches (keep_secs, shdr_info[cnt].name))
1382 shdr_info[cnt].idx = 0;
1384 idx = shdr_info[cnt].group_idx;
1422 for (cnt = 1; cnt < shnum; ++cnt)
1424 if (shdr_info[cnt].idx == 0)
1428 if (shdr_info[cnt].shdr.sh_type == SHT_REL
1429 || shdr_info[cnt].shdr.sh_type == SHT_RELA)
1431 if (shdr_info[cnt].shdr.sh_info >= shnum)
1433 else if (shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0)
1434 shdr_info[cnt].idx = 1;
1439 if (shdr_info[cnt].shdr.sh_type == SHT_GROUP)
1442 grpref = (Elf32_Word *) shdr_info[cnt].data->d_buf;
1444 in < shdr_info[cnt].data->d_size / sizeof (Elf32_Word);
1450 shdr_info[cnt].idx = 1;
1459 if (shdr_info[cnt].idx == 1)
1465 && shdr_info[cnt].debug_data == NULL
1466 && (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM
1467 || shdr_info[cnt].shdr.sh_type == SHT_SYMTAB))
1470 if (shdr_info[cnt].data == NULL)
1472 shdr_info[cnt].data
1473 = elf_getdata (shdr_info[cnt].scn, NULL);
1474 if (shdr_info[cnt].data == NULL)
1477 Elf_Data *symdata = shdr_info[cnt].data;
1481 if (shdr_info[cnt].symtab_idx != 0
1482 && shdr_info[shdr_info[cnt].symtab_idx].data == NULL)
1484 elf_assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB);
1486 shdr_info[shdr_info[cnt].symtab_idx].data
1487 = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn,
1489 if (shdr_info[shdr_info[cnt].symtab_idx].data == NULL)
1493 = shdr_info[shdr_info[cnt].symtab_idx].data;
1500 inner < shdr_info[cnt].data->d_size / elsize;
1539 shdr_info[cnt].shdr.sh_link,
1541 shdr_info[cnt].debug_data = symdata;
1560 if (shdr_info[shdr_info[cnt].shdr.sh_link].idx == 0)
1562 shdr_info[shdr_info[cnt].shdr.sh_link].idx = 1;
1563 changes |= shdr_info[cnt].shdr.sh_link < cnt;
1567 if (SH_INFO_LINK_P (&shdr_info[cnt].shdr))
1569 if (shdr_info[cnt].shdr.sh_info >= shnum)
1571 else if ( shdr_info[shdr_info[cnt].shdr.sh_info].idx == 0)
1573 shdr_info[shdr_info[cnt].shdr.sh_info].idx = 1;
1574 changes |= shdr_info[cnt].shdr.sh_info < cnt;
1579 shdr_info[cnt].idx = 2;
1583 && (shdr_info[cnt].idx == 0 || shdr_info[cnt].debug_data != NULL))
1592 size_t shdr_indices[2] = { shdr_info[cnt].shdr.sh_link, 0 };
1595 if (SH_INFO_LINK_P (&shdr_info[cnt].shdr))
1597 shdr_indices[1] = shdr_info[cnt].shdr.sh_info;
1613 changes |= i < cnt;
1625 for (cnt = 1; cnt < shnum; ++cnt)
1635 bool discard_section = (shdr_info[cnt].idx > 0
1636 && shdr_info[cnt].debug_data == NULL
1637 && shdr_info[cnt].shdr.sh_type != SHT_NOTE
1638 && shdr_info[cnt].shdr.sh_type != SHT_GROUP
1639 && cnt != shstrndx);
1642 GElf_Shdr debugshdr = shdr_info[cnt].shdr;
1651 if (shdr_info[cnt].data == NULL)
1653 shdr_info[cnt].data = elf_getdata (shdr_info[cnt].scn, NULL);
1654 if (shdr_info[cnt].data == NULL)
1665 *debugdata = *shdr_info[cnt].data;
1668 else if (shdr_info[cnt].debug_data != NULL
1669 || shdr_info[cnt].shdr.sh_type == SHT_GROUP)
1672 shdr_info[cnt].debug_data = debugdata;
1735 for (cnt = idx = 1; cnt < shnum; ++cnt)
1736 if (shdr_info[cnt].idx > 0)
1738 shdr_info[cnt].idx = idx++;
1741 shdr_info[cnt].newscn = elf_newscn (newelf);
1742 if (shdr_info[cnt].newscn == NULL)
1750 elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx);
1753 shdr_info[cnt].se = dwelf_strtab_add (shst, shdr_info[cnt].name);
1759 bool removing_sections = !(cnt == idx
1760 || (cnt == idx + 1
1769 shdr_info[cnt].se = dwelf_strtab_add_len (shst, ".gnu_debuglink", 15);
1770 shdr_info[cnt].idx = idx++;
1773 shdr_info[cnt].shdr.sh_type = SHT_PROGBITS;
1774 shdr_info[cnt].shdr.sh_flags = 0;
1775 shdr_info[cnt].shdr.sh_addr = 0;
1776 shdr_info[cnt].shdr.sh_link = SHN_UNDEF;
1777 shdr_info[cnt].shdr.sh_info = SHN_UNDEF;
1778 shdr_info[cnt].shdr.sh_entsize = 0;
1779 shdr_info[cnt].shdr.sh_addralign = 4;
1783 shdr_info[cnt].shdr.sh_offset = 0;
1786 shdr_info[cnt].newscn = elf_newscn (newelf);
1787 if (shdr_info[cnt].newscn == NULL)
1793 elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx);
1795 shdr_info[cnt].data = elf_newdata (shdr_info[cnt].newscn);
1796 if (shdr_info[cnt].data == NULL)
1808 shdr_info[cnt].data->d_align = 4;
1809 shdr_info[cnt].shdr.sh_size = shdr_info[cnt].data->d_size
1811 debuglink_buf = xcalloc (1, shdr_info[cnt].data->d_size);
1812 shdr_info[cnt].data->d_buf = debuglink_buf;
1814 strcpy (shdr_info[cnt].data->d_buf, debug_basename);
1818 debuglink_crc_data = *shdr_info[cnt].data;
1824 ++cnt;
1828 shdridx = cnt;
1831 shdr_info[cnt].se = dwelf_strtab_add_len (shst, ".shstrtab", 10);
1832 shdr_info[cnt].idx = idx;
1835 shdr_info[cnt].shdr.sh_type = SHT_STRTAB;
1836 shdr_info[cnt].shdr.sh_flags = 0;
1837 shdr_info[cnt].shdr.sh_addr = 0;
1838 shdr_info[cnt].shdr.sh_link = SHN_UNDEF;
1839 shdr_info[cnt].shdr.sh_info = SHN_UNDEF;
1840 shdr_info[cnt].shdr.sh_entsize = 0;
1844 shdr_info[cnt].shdr.sh_offset = 0;
1845 shdr_info[cnt].shdr.sh_addralign = 1;
1848 shdr_info[cnt].newscn = elf_newscn (newelf);
1849 if (shdr_info[cnt].newscn == NULL)
1855 elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == idx);
1859 shstrtab_data = elf_newdata (shdr_info[cnt].newscn);
1873 shdr_info[cnt].shdr.sh_size = shstrtab_data->d_size;
1877 for (cnt = 1; cnt <= shdridx; ++cnt)
1878 if (shdr_info[cnt].idx > 0)
1882 scn = elf_getscn (newelf, shdr_info[cnt].idx);
1886 shdr_info[cnt].shdr.sh_name = dwelf_strent_off (shdr_info[cnt].se);
1892 size_t sh_link = shdr_info[cnt].shdr.sh_link;
1893 if (shdr_info[cnt].shdr.sh_link != 0)
1894 shdr_info[cnt].shdr.sh_link =
1895 shdr_info[shdr_info[cnt].shdr.sh_link].idx;
1897 if (shdr_info[cnt].shdr.sh_type == SHT_GROUP)
1899 elf_assert (shdr_info[cnt].data != NULL
1900 && shdr_info[cnt].data->d_buf != NULL);
1902 Elf32_Word *grpref = (Elf32_Word *) shdr_info[cnt].data->d_buf;
1906 inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word);
1915 if (SH_INFO_LINK_P (&shdr_info[cnt].shdr))
1916 shdr_info[cnt].shdr.sh_info =
1917 shdr_info[shdr_info[cnt].shdr.sh_info].idx;
1921 if (cnt < shnum)
1923 if (shdr_info[cnt].data == NULL)
1925 shdr_info[cnt].data = elf_getdata (shdr_info[cnt].scn, NULL);
1926 if (shdr_info[cnt].data == NULL)
1936 *newdata = *shdr_info[cnt].data;
1939 shdr_info[cnt].shdr.sh_size = shdr_info[cnt].data->d_size;
1943 if (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM
1944 || shdr_info[cnt].shdr.sh_type == SHT_SYMTAB)
1951 if (shdr_info[cnt].symtab_idx != 0)
1953 elf_assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX);
1956 shndxdata = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn,
1962 >= shdr_info[cnt].data->d_size / elsize));
1965 if (shdr_info[cnt].version_idx != 0)
1967 elf_assert (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM);
1971 versiondata = elf_getdata (shdr_info[shdr_info[cnt].version_idx].scn,
1977 >= shdr_info[cnt].data->d_size / elsize));
1980 shdr_info[cnt].newsymidx
1981 = xcalloc (shdr_info[cnt].data->d_size / elsize,
1988 inner < shdr_info[cnt].data->d_size / elsize;
1994 GElf_Sym *sym = gelf_getsymshndx (shdr_info[cnt].data,
2007 && gelf_update_symshndx (shdr_info[cnt].data,
2013 shdr_info[cnt].newsymidx[inner] = destidx++;
2019 shdr_info[cnt].shdr.sh_info = destidx - 1;
2056 gelf_update_symshndx (shdr_info[cnt].data,
2062 shdr_info[cnt].newsymidx[inner] = destidx++;
2068 shdr_info[cnt].shdr.sh_info = destidx - 1;
2071 else if ((shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) != 0
2082 _("Cannot remove symbol [%zd] from allocated symbol table [%zd]"), inner, cnt);
2084 if (gelf_update_sym (shdr_info[cnt].data, destidx,
2087 shdr_info[cnt].newsymidx[inner] = destidx++;
2090 && shdr_info[cnt].debug_data == NULL)
2111 shdr_info[cnt].shdr.sh_size = newdata->d_size
2118 free (shdr_info[cnt].newsymidx);
2119 shdr_info[cnt].newsymidx = NULL;
2128 || (shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) != 0)
2130 if (shdr_info[cnt].shdr.sh_offset == 0)
2131 shdr_info[cnt].shdr.sh_offset
2132 = ((lastoffset + shdr_info[cnt].shdr.sh_addralign - 1)
2133 & ~((GElf_Off) (shdr_info[cnt].shdr.sh_addralign - 1)));
2136 if (unlikely (gelf_update_shdr (scn, &shdr_info[cnt].shdr) == 0))
2141 GElf_Off filesz = (shdr_info[cnt].shdr.sh_type != SHT_NOBITS
2142 ? shdr_info[cnt].shdr.sh_size : 0);
2143 if (lastoffset < shdr_info[cnt].shdr.sh_offset + filesz)
2144 lastoffset = shdr_info[cnt].shdr.sh_offset + filesz;
2152 for (cnt = 1; cnt <= shdridx; ++cnt)
2153 if (shdr_info[cnt].idx > 0)
2155 scn = elf_getscn (newelf, shdr_info[cnt].idx);
2156 if ((shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) == 0)
2158 if (shdr_info[cnt].shdr.sh_offset == 0)
2159 shdr_info[cnt].shdr.sh_offset
2160 = ((lastoffset + shdr_info[cnt].shdr.sh_addralign - 1)
2161 & ~((GElf_Off) (shdr_info[cnt].shdr.sh_addralign - 1)));
2164 if (unlikely (gelf_update_shdr (scn, &shdr_info[cnt].shdr) == 0))
2169 GElf_Off filesz = (shdr_info[cnt].shdr.sh_type != SHT_NOBITS
2170 ? shdr_info[cnt].shdr.sh_size : 0);
2171 if (lastoffset < shdr_info[cnt].shdr.sh_offset + filesz)
2172 lastoffset = shdr_info[cnt].shdr.sh_offset + filesz;
2179 for (cnt = 1; cnt <= shdridx; ++cnt)
2181 struct shdr_info *info = &shdr_info[cnt];
2207 ? elf_getscn (debugelf, cnt)
2301 update_section_size (scn, hashd, debugelf, cnt, fname);
2362 update_section_size (scn, hashd, debugelf, cnt, fname);
2433 update_section_size (scn, verd, debugelf, cnt, fname);
2635 for (cnt = 1; cnt <= shdridx; ++cnt)
2637 free (shdr_info[cnt].newsymidx);
2638 if (shdr_info[cnt].debug_data != NULL)
2639 free (shdr_info[cnt].debug_data->d_buf);