Lines Matching defs:shdr_info

574 	 not just the cached original in shdr_info because we
995 struct shdr_info
1011 } *shdr_info = NULL;
1202 if ((shnum + 2) * sizeof (struct shdr_info) > MAX_STACK_ALLOC)
1203 shdr_info = xcalloc (shnum + 2, sizeof (struct shdr_info));
1206 shdr_info = (struct shdr_info *) alloca ((shnum + 2)
1207 * sizeof (struct shdr_info));
1208 memset (shdr_info, '\0', (shnum + 2) * sizeof (struct shdr_info));
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;
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,
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;
1388 elf_assert (shdr_info[idx].data != NULL
1389 && shdr_info[idx].data->d_buf != NULL
1390 && shdr_info[idx].data->d_size >= sizeof (Elf32_Word));
1395 bool is_comdat = (((Elf32_Word *) shdr_info[idx].data->d_buf)[0]
1398 --shdr_info[idx].group_cnt;
1399 if ((!is_comdat && shdr_info[idx].group_cnt == 1)
1400 || (is_comdat && shdr_info[idx].group_cnt == 0))
1402 shdr_info[idx].idx = 0;
1404 idx = shdr_info[idx].group_idx;
1412 shdr_info[0].idx = 2;
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);
1448 if (shdr_info[grpref[in]].idx != 0)
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;
1526 if (shdr_info[scnidx].idx == 0)
1533 &shdr_info[scnidx].shdr,
1534 shdr_info[scnidx].name,
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;
1604 if (i != 0 && i < shnum + 2 && shdr_info[i].idx != 0
1605 && shdr_info[i].debug_data == NULL)
1607 if (shdr_info[i].data == NULL)
1608 shdr_info[i].data = elf_getdata (shdr_info[i].scn, NULL);
1609 if (shdr_info[i].data == NULL)
1612 shdr_info[i].debug_data = shdr_info[i].data;
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
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;
1734 shdr_info[0].idx = 0;
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);
1761 && shdr_info[shstrndx].idx == 0));
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;
1827 /* Index of the section header table in the shdr_info array. */
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;
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);
1909 grpref[inner] = shdr_info[grpref[inner]].idx;
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;
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;
2033 sec = shdr_info[sidx].idx;
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
2073 && shdr_info[sidx].shdr.sh_type != SHT_GROUP)
2084 if (gelf_update_sym (shdr_info[cnt].data, destidx,
2087 shdr_info[cnt].newsymidx[inner] = destidx++;
2090 && shdr_info[cnt].debug_data == NULL)
2098 || ((shdr_info[sidx].shdr.sh_type
2100 && (shdr_info[sidx].shdr.sh_info
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;
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;
2181 struct shdr_info *info = &shdr_info[cnt];
2190 const Elf32_Word *const newsymidx = shdr_info[symtabidx].newsymidx;
2199 if (info->idx == 0 && shdr_info[symtabidx].debug_data != NULL)
2215 const Elf32_Word symidxn = (shdr_info[symtabidx].data->d_size
2267 shdr_info[symtabidx].idx),
2281 size_t strshndx = shdr_info[symtabidx].old_sh_link;
2308 for (size_t inner = shdr_info[symtabidx].shdr.sh_info;
2340 size_t strshndx = shdr_info[symtabidx].old_sh_link;
2369 for (size_t inner = shdr_info[symtabidx].shdr.sh_info;
2404 symd = elf_getdata (elf_getscn (newelf, shdr_info[symtabidx].idx),
2408 const Elf32_Word syms = (shdr_info[symtabidx].data->d_size / symz);
2445 const Elf32_Word symn = (shdr_info[symtabidx].data->d_size
2518 lastsec_offset = shdr_info[shdridx].shdr.sh_offset;
2519 lastsec_size = shdr_info[shdridx].shdr.sh_size;
2630 if (shdr_info != NULL)
2637 free (shdr_info[cnt].newsymidx);
2638 if (shdr_info[cnt].debug_data != NULL)
2639 free (shdr_info[cnt].debug_data->d_buf);
2646 if ((shnum + 2) * sizeof (struct shdr_info) > MAX_STACK_ALLOC)
2647 free (shdr_info);