Lines Matching refs:cnt
957 size_t cnt; in handle_elf() local
1075 for (cnt = 0; cnt < phnum; ++cnt) in handle_elf()
1078 GElf_Phdr *phdr = gelf_getphdr (elf, cnt, &phdr_mem); in handle_elf()
1080 || unlikely (gelf_update_phdr (newelf, cnt, phdr) == 0)) in handle_elf()
1118 for (cnt = 0; cnt < phnum; ++cnt) in handle_elf()
1121 GElf_Phdr *phdr = gelf_getphdr (elf, cnt, &phdr_mem); in handle_elf()
1123 || unlikely (gelf_update_phdr (debugelf, cnt, phdr) == 0)) in handle_elf()
1164 cnt = 1; in handle_elf()
1169 elf_assert (elf_ndxscn (scn) == cnt); in handle_elf()
1171 shdr_info[cnt].scn = scn; in handle_elf()
1174 if (gelf_getshdr (scn, &shdr_info[cnt].shdr) == NULL) in handle_elf()
1179 if ((shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) == 0) in handle_elf()
1189 shdr_info[cnt].name = elf_strptr (elf, shstrndx, in handle_elf()
1190 shdr_info[cnt].shdr.sh_name); in handle_elf()
1191 if (shdr_info[cnt].name == NULL) in handle_elf()
1199 if (section_name_matches (remove_secs, shdr_info[cnt].name)) in handle_elf()
1201 if ((shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) != 0) in handle_elf()
1205 shdr_info[cnt].name); in handle_elf()
1210 if (section_name_matches (keep_secs, shdr_info[cnt].name)) in handle_elf()
1214 shdr_info[cnt].name); in handle_elf()
1221 shdr_info[cnt].idx = 1; in handle_elf()
1224 shdr_info[cnt].old_sh_link = shdr_info[cnt].shdr.sh_link; in handle_elf()
1225 if (shdr_info[cnt].old_sh_link >= shnum) in handle_elf()
1235 || (shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) == 0) in handle_elf()
1236 shdr_info[cnt].shdr.sh_offset = 0; in handle_elf()
1240 if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX)) in handle_elf()
1242 elf_assert (shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0); in handle_elf()
1243 shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx = cnt; in handle_elf()
1245 else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GROUP)) in handle_elf()
1249 shdr_info[cnt].data = elf_getdata (shdr_info[cnt].scn, NULL); in handle_elf()
1250 if (shdr_info[cnt].data == NULL in handle_elf()
1251 || shdr_info[cnt].data->d_size < sizeof (Elf32_Word)) in handle_elf()
1255 Elf32_Word *grpref = (Elf32_Word *) shdr_info[cnt].data->d_buf; in handle_elf()
1258 inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word); in handle_elf()
1262 shdr_info[grpref[inner]].group_idx = cnt; in handle_elf()
1270 shdr_info[cnt].idx = 0; in handle_elf()
1272 shdr_info[cnt].group_cnt = inner - 1; in handle_elf()
1274 else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GNU_versym)) in handle_elf()
1276 elf_assert (shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0); in handle_elf()
1277 shdr_info[shdr_info[cnt].shdr.sh_link].version_idx = cnt; in handle_elf()
1282 if ((shdr_info[cnt].shdr.sh_flags & SHF_GROUP) != 0) in handle_elf()
1284 elf_assert (shdr_info[cnt].group_idx != 0); in handle_elf()
1286 if (shdr_info[shdr_info[cnt].group_idx].idx == 0) in handle_elf()
1294 shdr_info[cnt].group_idx = 0; in handle_elf()
1299 ++cnt; in handle_elf()
1313 for (cnt = 1; cnt < shnum; ++cnt) in handle_elf()
1316 if (remove_shdrs ? !(shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) in handle_elf()
1317 : (ebl_section_strip_p (ebl, &shdr_info[cnt].shdr, in handle_elf()
1318 shdr_info[cnt].name, remove_comment, in handle_elf()
1320 || cnt == shstrndx in handle_elf()
1321 || section_name_matches (remove_secs, shdr_info[cnt].name))) in handle_elf()
1324 if (section_name_matches (keep_secs, shdr_info[cnt].name)) in handle_elf()
1328 shdr_info[cnt].idx = 0; in handle_elf()
1330 idx = shdr_info[cnt].group_idx; in handle_elf()
1368 for (cnt = 1; cnt < shnum; ++cnt) in handle_elf()
1370 if (shdr_info[cnt].idx == 0) in handle_elf()
1374 if (shdr_info[cnt].shdr.sh_type == SHT_REL in handle_elf()
1375 || shdr_info[cnt].shdr.sh_type == SHT_RELA) in handle_elf()
1377 if (shdr_info[cnt].shdr.sh_info >= shnum) in handle_elf()
1379 else if (shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0) in handle_elf()
1380 shdr_info[cnt].idx = 1; in handle_elf()
1385 if (shdr_info[cnt].shdr.sh_type == SHT_GROUP) in handle_elf()
1388 grpref = (Elf32_Word *) shdr_info[cnt].data->d_buf; in handle_elf()
1390 in < shdr_info[cnt].data->d_size / sizeof (Elf32_Word); in handle_elf()
1396 shdr_info[cnt].idx = 1; in handle_elf()
1405 if (shdr_info[cnt].idx == 1) in handle_elf()
1411 && shdr_info[cnt].debug_data == NULL in handle_elf()
1412 && (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM in handle_elf()
1413 || shdr_info[cnt].shdr.sh_type == SHT_SYMTAB)) in handle_elf()
1416 if (shdr_info[cnt].data == NULL) in handle_elf()
1418 shdr_info[cnt].data in handle_elf()
1419 = elf_getdata (shdr_info[cnt].scn, NULL); in handle_elf()
1420 if (shdr_info[cnt].data == NULL) in handle_elf()
1423 Elf_Data *symdata = shdr_info[cnt].data; in handle_elf()
1427 if (shdr_info[cnt].symtab_idx != 0 in handle_elf()
1428 && shdr_info[shdr_info[cnt].symtab_idx].data == NULL) in handle_elf()
1430 elf_assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB); in handle_elf()
1432 shdr_info[shdr_info[cnt].symtab_idx].data in handle_elf()
1433 = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn, in handle_elf()
1435 if (shdr_info[shdr_info[cnt].symtab_idx].data == NULL) in handle_elf()
1439 = shdr_info[shdr_info[cnt].symtab_idx].data; in handle_elf()
1446 inner < shdr_info[cnt].data->d_size / elsize; in handle_elf()
1485 shdr_info[cnt].shdr.sh_link, in handle_elf()
1487 shdr_info[cnt].debug_data = symdata; in handle_elf()
1506 if (shdr_info[shdr_info[cnt].shdr.sh_link].idx == 0) in handle_elf()
1508 shdr_info[shdr_info[cnt].shdr.sh_link].idx = 1; in handle_elf()
1509 changes |= shdr_info[cnt].shdr.sh_link < cnt; in handle_elf()
1513 if (SH_INFO_LINK_P (&shdr_info[cnt].shdr)) in handle_elf()
1515 if (shdr_info[cnt].shdr.sh_info >= shnum) in handle_elf()
1517 else if ( shdr_info[shdr_info[cnt].shdr.sh_info].idx == 0) in handle_elf()
1519 shdr_info[shdr_info[cnt].shdr.sh_info].idx = 1; in handle_elf()
1520 changes |= shdr_info[cnt].shdr.sh_info < cnt; in handle_elf()
1525 shdr_info[cnt].idx = 2; in handle_elf()
1529 && (shdr_info[cnt].idx == 0 || shdr_info[cnt].debug_data != NULL)) in handle_elf()
1550 changes |= i < cnt; in handle_elf()
1554 check_preserved (shdr_info[cnt].shdr.sh_link); in handle_elf()
1555 if (SH_INFO_LINK_P (&shdr_info[cnt].shdr)) in handle_elf()
1556 check_preserved (shdr_info[cnt].shdr.sh_info); in handle_elf()
1566 for (cnt = 1; cnt < shnum; ++cnt) in handle_elf()
1577 bool discard_section = (shdr_info[cnt].idx > 0 in handle_elf()
1578 && shdr_info[cnt].debug_data == NULL in handle_elf()
1579 && shdr_info[cnt].shdr.sh_type != SHT_NOTE in handle_elf()
1580 && shdr_info[cnt].shdr.sh_type != SHT_GROUP in handle_elf()
1581 && cnt != shstrndx); in handle_elf()
1584 GElf_Shdr debugshdr = shdr_info[cnt].shdr; in handle_elf()
1593 if (shdr_info[cnt].data == NULL) in handle_elf()
1595 shdr_info[cnt].data = elf_getdata (shdr_info[cnt].scn, NULL); in handle_elf()
1596 if (shdr_info[cnt].data == NULL) in handle_elf()
1607 *debugdata = *shdr_info[cnt].data; in handle_elf()
1610 else if (shdr_info[cnt].debug_data != NULL in handle_elf()
1611 || shdr_info[cnt].shdr.sh_type == SHT_GROUP) in handle_elf()
1614 shdr_info[cnt].debug_data = debugdata; in handle_elf()
1677 for (cnt = idx = 1; cnt < shnum; ++cnt) in handle_elf()
1678 if (shdr_info[cnt].idx > 0) in handle_elf()
1680 shdr_info[cnt].idx = idx++; in handle_elf()
1683 shdr_info[cnt].newscn = elf_newscn (newelf); in handle_elf()
1684 if (shdr_info[cnt].newscn == NULL) in handle_elf()
1692 elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx); in handle_elf()
1695 shdr_info[cnt].se = dwelf_strtab_add (shst, shdr_info[cnt].name); in handle_elf()
1701 bool removing_sections = !(cnt == idx in handle_elf()
1702 || (cnt == idx + 1 in handle_elf()
1711 shdr_info[cnt].se = dwelf_strtab_add_len (shst, ".gnu_debuglink", 15); in handle_elf()
1712 shdr_info[cnt].idx = idx++; in handle_elf()
1715 shdr_info[cnt].shdr.sh_type = SHT_PROGBITS; in handle_elf()
1716 shdr_info[cnt].shdr.sh_flags = 0; in handle_elf()
1717 shdr_info[cnt].shdr.sh_addr = 0; in handle_elf()
1718 shdr_info[cnt].shdr.sh_link = SHN_UNDEF; in handle_elf()
1719 shdr_info[cnt].shdr.sh_info = SHN_UNDEF; in handle_elf()
1720 shdr_info[cnt].shdr.sh_entsize = 0; in handle_elf()
1721 shdr_info[cnt].shdr.sh_addralign = 4; in handle_elf()
1725 shdr_info[cnt].shdr.sh_offset = 0; in handle_elf()
1728 shdr_info[cnt].newscn = elf_newscn (newelf); in handle_elf()
1729 if (shdr_info[cnt].newscn == NULL) in handle_elf()
1736 elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx); in handle_elf()
1738 shdr_info[cnt].data = elf_newdata (shdr_info[cnt].newscn); in handle_elf()
1739 if (shdr_info[cnt].data == NULL) in handle_elf()
1751 shdr_info[cnt].data->d_align = 4; in handle_elf()
1752 shdr_info[cnt].shdr.sh_size = shdr_info[cnt].data->d_size in handle_elf()
1754 debuglink_buf = xcalloc (1, shdr_info[cnt].data->d_size); in handle_elf()
1755 shdr_info[cnt].data->d_buf = debuglink_buf; in handle_elf()
1757 strcpy (shdr_info[cnt].data->d_buf, debug_basename); in handle_elf()
1761 debuglink_crc_data = *shdr_info[cnt].data; in handle_elf()
1767 ++cnt; in handle_elf()
1771 shdridx = cnt; in handle_elf()
1774 shdr_info[cnt].se = dwelf_strtab_add_len (shst, ".shstrtab", 10); in handle_elf()
1775 shdr_info[cnt].idx = idx; in handle_elf()
1778 shdr_info[cnt].shdr.sh_type = SHT_STRTAB; in handle_elf()
1779 shdr_info[cnt].shdr.sh_flags = 0; in handle_elf()
1780 shdr_info[cnt].shdr.sh_addr = 0; in handle_elf()
1781 shdr_info[cnt].shdr.sh_link = SHN_UNDEF; in handle_elf()
1782 shdr_info[cnt].shdr.sh_info = SHN_UNDEF; in handle_elf()
1783 shdr_info[cnt].shdr.sh_entsize = 0; in handle_elf()
1787 shdr_info[cnt].shdr.sh_offset = 0; in handle_elf()
1788 shdr_info[cnt].shdr.sh_addralign = 1; in handle_elf()
1791 shdr_info[cnt].newscn = elf_newscn (newelf); in handle_elf()
1792 if (shdr_info[cnt].newscn == NULL) in handle_elf()
1799 elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == idx); in handle_elf()
1803 shstrtab_data = elf_newdata (shdr_info[cnt].newscn); in handle_elf()
1819 shdr_info[cnt].shdr.sh_size = shstrtab_data->d_size; in handle_elf()
1823 for (cnt = 1; cnt <= shdridx; ++cnt) in handle_elf()
1824 if (shdr_info[cnt].idx > 0) in handle_elf()
1828 scn = elf_getscn (newelf, shdr_info[cnt].idx); in handle_elf()
1832 shdr_info[cnt].shdr.sh_name = dwelf_strent_off (shdr_info[cnt].se); in handle_elf()
1838 size_t sh_link = shdr_info[cnt].shdr.sh_link; in handle_elf()
1839 if (shdr_info[cnt].shdr.sh_link != 0) in handle_elf()
1840 shdr_info[cnt].shdr.sh_link = in handle_elf()
1841 shdr_info[shdr_info[cnt].shdr.sh_link].idx; in handle_elf()
1843 if (shdr_info[cnt].shdr.sh_type == SHT_GROUP) in handle_elf()
1845 elf_assert (shdr_info[cnt].data != NULL in handle_elf()
1846 && shdr_info[cnt].data->d_buf != NULL); in handle_elf()
1848 Elf32_Word *grpref = (Elf32_Word *) shdr_info[cnt].data->d_buf; in handle_elf()
1852 inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word); in handle_elf()
1861 if (SH_INFO_LINK_P (&shdr_info[cnt].shdr)) in handle_elf()
1862 shdr_info[cnt].shdr.sh_info = in handle_elf()
1863 shdr_info[shdr_info[cnt].shdr.sh_info].idx; in handle_elf()
1867 if (cnt < shnum) in handle_elf()
1869 if (shdr_info[cnt].data == NULL) in handle_elf()
1871 shdr_info[cnt].data = elf_getdata (shdr_info[cnt].scn, NULL); in handle_elf()
1872 if (shdr_info[cnt].data == NULL) in handle_elf()
1882 *newdata = *shdr_info[cnt].data; in handle_elf()
1885 shdr_info[cnt].shdr.sh_size = shdr_info[cnt].data->d_size; in handle_elf()
1889 if (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM in handle_elf()
1890 || shdr_info[cnt].shdr.sh_type == SHT_SYMTAB) in handle_elf()
1897 if (shdr_info[cnt].symtab_idx != 0) in handle_elf()
1899 elf_assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX); in handle_elf()
1902 shndxdata = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn, in handle_elf()
1908 >= shdr_info[cnt].data->d_size / elsize)); in handle_elf()
1911 if (shdr_info[cnt].version_idx != 0) in handle_elf()
1913 elf_assert (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM); in handle_elf()
1917 versiondata = elf_getdata (shdr_info[shdr_info[cnt].version_idx].scn, in handle_elf()
1923 >= shdr_info[cnt].data->d_size / elsize)); in handle_elf()
1926 shdr_info[cnt].newsymidx in handle_elf()
1927 = (Elf32_Word *) xcalloc (shdr_info[cnt].data->d_size in handle_elf()
1934 inner < shdr_info[cnt].data->d_size / elsize; in handle_elf()
1940 GElf_Sym *sym = gelf_getsymshndx (shdr_info[cnt].data, in handle_elf()
1953 && gelf_update_symshndx (shdr_info[cnt].data, in handle_elf()
1959 shdr_info[cnt].newsymidx[inner] = destidx++; in handle_elf()
1965 shdr_info[cnt].shdr.sh_info = destidx - 1; in handle_elf()
2001 gelf_update_symshndx (shdr_info[cnt].data, in handle_elf()
2007 shdr_info[cnt].newsymidx[inner] = destidx++; in handle_elf()
2013 shdr_info[cnt].shdr.sh_info = destidx - 1; in handle_elf()
2016 else if ((shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) != 0 in handle_elf()
2027 gettext ("Cannot remove symbol [%zd] from allocated symbol table [%zd]"), inner, cnt); in handle_elf()
2029 if (gelf_update_sym (shdr_info[cnt].data, destidx, in handle_elf()
2032 shdr_info[cnt].newsymidx[inner] = destidx++; in handle_elf()
2035 && shdr_info[cnt].debug_data == NULL) in handle_elf()
2056 shdr_info[cnt].shdr.sh_size = newdata->d_size in handle_elf()
2063 free (shdr_info[cnt].newsymidx); in handle_elf()
2064 shdr_info[cnt].newsymidx = NULL; in handle_elf()
2073 || (shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) != 0) in handle_elf()
2075 if (shdr_info[cnt].shdr.sh_offset == 0) in handle_elf()
2076 shdr_info[cnt].shdr.sh_offset in handle_elf()
2077 = ((lastoffset + shdr_info[cnt].shdr.sh_addralign - 1) in handle_elf()
2078 & ~((GElf_Off) (shdr_info[cnt].shdr.sh_addralign - 1))); in handle_elf()
2081 if (unlikely (gelf_update_shdr (scn, &shdr_info[cnt].shdr) == 0)) in handle_elf()
2086 GElf_Off filesz = (shdr_info[cnt].shdr.sh_type != SHT_NOBITS in handle_elf()
2087 ? shdr_info[cnt].shdr.sh_size : 0); in handle_elf()
2088 if (lastoffset < shdr_info[cnt].shdr.sh_offset + filesz) in handle_elf()
2089 lastoffset = shdr_info[cnt].shdr.sh_offset + filesz; in handle_elf()
2097 for (cnt = 1; cnt <= shdridx; ++cnt) in handle_elf()
2098 if (shdr_info[cnt].idx > 0) in handle_elf()
2100 scn = elf_getscn (newelf, shdr_info[cnt].idx); in handle_elf()
2101 if ((shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) == 0) in handle_elf()
2103 if (shdr_info[cnt].shdr.sh_offset == 0) in handle_elf()
2104 shdr_info[cnt].shdr.sh_offset in handle_elf()
2105 = ((lastoffset + shdr_info[cnt].shdr.sh_addralign - 1) in handle_elf()
2106 & ~((GElf_Off) (shdr_info[cnt].shdr.sh_addralign - 1))); in handle_elf()
2109 if (unlikely (gelf_update_shdr (scn, &shdr_info[cnt].shdr) == 0)) in handle_elf()
2114 GElf_Off filesz = (shdr_info[cnt].shdr.sh_type != SHT_NOBITS in handle_elf()
2115 ? shdr_info[cnt].shdr.sh_size : 0); in handle_elf()
2116 if (lastoffset < shdr_info[cnt].shdr.sh_offset + filesz) in handle_elf()
2117 lastoffset = shdr_info[cnt].shdr.sh_offset + filesz; in handle_elf()
2124 for (cnt = 1; cnt <= shdridx; ++cnt) in handle_elf()
2139 cnt), NULL); in handle_elf()
2146 if (shdr_info[cnt].idx == 0 && debug_fname == NULL) in handle_elf()
2152 const Elf32_Word symtabidx = shdr_info[cnt].old_sh_link; in handle_elf()
2155 switch (shdr_info[cnt].shdr.sh_type) in handle_elf()
2166 return (shdr_info[cnt].idx == 0 in handle_elf()
2175 Elf_Data *d = elf_getdata (shdr_info[cnt].idx == 0 in handle_elf()
2176 ? elf_getscn (debugelf, cnt) in handle_elf()
2178 shdr_info[cnt].idx), in handle_elf()
2181 && shdr_info[cnt].shdr.sh_entsize != 0); in handle_elf()
2182 size_t nrels = (shdr_info[cnt].shdr.sh_size in handle_elf()
2183 / shdr_info[cnt].shdr.sh_entsize); in handle_elf()
2188 if (shdr_info[cnt].shdr.sh_type == SHT_REL) in handle_elf()
2234 elf_assert (shdr_info[cnt].idx > 0); in handle_elf()
2237 scn = elf_getscn (newelf, shdr_info[cnt].idx); in handle_elf()
2249 if (shdr_info[cnt].shdr.sh_entsize == sizeof (Elf32_Word)) in handle_elf()
2310 elf_assert (shdr_info[cnt].shdr.sh_entsize in handle_elf()
2376 elf_assert (shdr_info[cnt].idx > 0); in handle_elf()
2379 scn = elf_getscn (newelf, shdr_info[cnt].idx); in handle_elf()
2420 scn = elf_getscn (newelf, shdr_info[cnt].idx); in handle_elf()
2616 for (cnt = 1; cnt <= shdridx; ++cnt) in handle_elf()
2618 free (shdr_info[cnt].newsymidx); in handle_elf()
2619 if (shdr_info[cnt].debug_data != NULL) in handle_elf()
2620 free (shdr_info[cnt].debug_data->d_buf); in handle_elf()