• Home
  • Raw
  • Download

Lines Matching refs:shdr_info

985   struct shdr_info  in handle_elf()  struct
1001 } *shdr_info = NULL; in handle_elf() local
1193 if ((shnum + 2) * sizeof (struct shdr_info) > MAX_STACK_ALLOC) in handle_elf()
1194 shdr_info = (struct shdr_info *) xcalloc (shnum + 2, in handle_elf()
1195 sizeof (struct shdr_info)); in handle_elf()
1198 shdr_info = (struct shdr_info *) alloca ((shnum + 2) in handle_elf()
1199 * sizeof (struct shdr_info)); in handle_elf()
1200 memset (shdr_info, '\0', (shnum + 2) * sizeof (struct shdr_info)); in handle_elf()
1217 shdr_info[cnt].scn = scn; in handle_elf()
1220 if (gelf_getshdr (scn, &shdr_info[cnt].shdr) == NULL) in handle_elf()
1225 if ((shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) == 0) in handle_elf()
1235 shdr_info[cnt].name = elf_strptr (elf, shstrndx, in handle_elf()
1236 shdr_info[cnt].shdr.sh_name); in handle_elf()
1237 if (shdr_info[cnt].name == NULL) in handle_elf()
1245 if (section_name_matches (remove_secs, shdr_info[cnt].name)) in handle_elf()
1247 if ((shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) != 0) in handle_elf()
1251 shdr_info[cnt].name); in handle_elf()
1256 if (section_name_matches (keep_secs, shdr_info[cnt].name)) in handle_elf()
1260 shdr_info[cnt].name); in handle_elf()
1267 shdr_info[cnt].idx = 1; in handle_elf()
1270 shdr_info[cnt].old_sh_link = shdr_info[cnt].shdr.sh_link; in handle_elf()
1271 if (shdr_info[cnt].old_sh_link >= shnum) in handle_elf()
1281 || (shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) == 0) in handle_elf()
1282 shdr_info[cnt].shdr.sh_offset = 0; in handle_elf()
1286 if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX)) in handle_elf()
1288 elf_assert (shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0); in handle_elf()
1289 shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx = cnt; in handle_elf()
1291 else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GROUP)) in handle_elf()
1295 shdr_info[cnt].data = elf_getdata (shdr_info[cnt].scn, NULL); in handle_elf()
1296 if (shdr_info[cnt].data == NULL in handle_elf()
1297 || shdr_info[cnt].data->d_size < sizeof (Elf32_Word)) in handle_elf()
1301 Elf32_Word *grpref = (Elf32_Word *) shdr_info[cnt].data->d_buf; in handle_elf()
1304 inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word); in handle_elf()
1308 shdr_info[grpref[inner]].group_idx = cnt; in handle_elf()
1316 shdr_info[cnt].idx = 0; in handle_elf()
1318 shdr_info[cnt].group_cnt = inner - 1; in handle_elf()
1320 else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GNU_versym)) in handle_elf()
1322 elf_assert (shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0); in handle_elf()
1323 shdr_info[shdr_info[cnt].shdr.sh_link].version_idx = cnt; in handle_elf()
1328 if ((shdr_info[cnt].shdr.sh_flags & SHF_GROUP) != 0) in handle_elf()
1330 elf_assert (shdr_info[cnt].group_idx != 0); in handle_elf()
1332 if (shdr_info[shdr_info[cnt].group_idx].idx == 0) in handle_elf()
1340 shdr_info[cnt].group_idx = 0; in handle_elf()
1362 if (remove_shdrs ? !(shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) in handle_elf()
1363 : (ebl_section_strip_p (ebl, &shdr_info[cnt].shdr, in handle_elf()
1364 shdr_info[cnt].name, remove_comment, in handle_elf()
1367 || section_name_matches (remove_secs, shdr_info[cnt].name))) in handle_elf()
1370 if (section_name_matches (keep_secs, shdr_info[cnt].name)) in handle_elf()
1374 shdr_info[cnt].idx = 0; in handle_elf()
1376 idx = shdr_info[cnt].group_idx; in handle_elf()
1380 elf_assert (shdr_info[idx].data != NULL in handle_elf()
1381 && shdr_info[idx].data->d_buf != NULL in handle_elf()
1382 && shdr_info[idx].data->d_size >= sizeof (Elf32_Word)); in handle_elf()
1387 bool is_comdat = (((Elf32_Word *) shdr_info[idx].data->d_buf)[0] in handle_elf()
1390 --shdr_info[idx].group_cnt; in handle_elf()
1391 if ((!is_comdat && shdr_info[idx].group_cnt == 1) in handle_elf()
1392 || (is_comdat && shdr_info[idx].group_cnt == 0)) in handle_elf()
1394 shdr_info[idx].idx = 0; in handle_elf()
1396 idx = shdr_info[idx].group_idx; in handle_elf()
1404 shdr_info[0].idx = 2; in handle_elf()
1416 if (shdr_info[cnt].idx == 0) in handle_elf()
1420 if (shdr_info[cnt].shdr.sh_type == SHT_REL in handle_elf()
1421 || shdr_info[cnt].shdr.sh_type == SHT_RELA) in handle_elf()
1423 if (shdr_info[cnt].shdr.sh_info >= shnum) in handle_elf()
1425 else if (shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0) in handle_elf()
1426 shdr_info[cnt].idx = 1; in handle_elf()
1431 if (shdr_info[cnt].shdr.sh_type == SHT_GROUP) in handle_elf()
1434 grpref = (Elf32_Word *) shdr_info[cnt].data->d_buf; in handle_elf()
1436 in < shdr_info[cnt].data->d_size / sizeof (Elf32_Word); in handle_elf()
1440 if (shdr_info[grpref[in]].idx != 0) in handle_elf()
1442 shdr_info[cnt].idx = 1; in handle_elf()
1451 if (shdr_info[cnt].idx == 1) in handle_elf()
1457 && shdr_info[cnt].debug_data == NULL in handle_elf()
1458 && (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM in handle_elf()
1459 || shdr_info[cnt].shdr.sh_type == SHT_SYMTAB)) in handle_elf()
1462 if (shdr_info[cnt].data == NULL) in handle_elf()
1464 shdr_info[cnt].data in handle_elf()
1465 = elf_getdata (shdr_info[cnt].scn, NULL); in handle_elf()
1466 if (shdr_info[cnt].data == NULL) in handle_elf()
1469 Elf_Data *symdata = shdr_info[cnt].data; in handle_elf()
1473 if (shdr_info[cnt].symtab_idx != 0 in handle_elf()
1474 && shdr_info[shdr_info[cnt].symtab_idx].data == NULL) in handle_elf()
1476 elf_assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB); in handle_elf()
1478 shdr_info[shdr_info[cnt].symtab_idx].data in handle_elf()
1479 = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn, in handle_elf()
1481 if (shdr_info[shdr_info[cnt].symtab_idx].data == NULL) in handle_elf()
1485 = shdr_info[shdr_info[cnt].symtab_idx].data; in handle_elf()
1492 inner < shdr_info[cnt].data->d_size / elsize; in handle_elf()
1518 if (shdr_info[scnidx].idx == 0) in handle_elf()
1525 &shdr_info[scnidx].shdr, in handle_elf()
1526 shdr_info[scnidx].name, in handle_elf()
1531 shdr_info[cnt].shdr.sh_link, in handle_elf()
1533 shdr_info[cnt].debug_data = symdata; in handle_elf()
1552 if (shdr_info[shdr_info[cnt].shdr.sh_link].idx == 0) in handle_elf()
1554 shdr_info[shdr_info[cnt].shdr.sh_link].idx = 1; in handle_elf()
1555 changes |= shdr_info[cnt].shdr.sh_link < cnt; in handle_elf()
1559 if (SH_INFO_LINK_P (&shdr_info[cnt].shdr)) in handle_elf()
1561 if (shdr_info[cnt].shdr.sh_info >= shnum) in handle_elf()
1563 else if ( shdr_info[shdr_info[cnt].shdr.sh_info].idx == 0) in handle_elf()
1565 shdr_info[shdr_info[cnt].shdr.sh_info].idx = 1; in handle_elf()
1566 changes |= shdr_info[cnt].shdr.sh_info < cnt; in handle_elf()
1571 shdr_info[cnt].idx = 2; in handle_elf()
1575 && (shdr_info[cnt].idx == 0 || shdr_info[cnt].debug_data != NULL)) in handle_elf()
1584 size_t shdr_indices[2] = { shdr_info[cnt].shdr.sh_link, 0 }; in handle_elf()
1587 if (SH_INFO_LINK_P (&shdr_info[cnt].shdr)) in handle_elf()
1589 shdr_indices[1] = shdr_info[cnt].shdr.sh_info; in handle_elf()
1596 if (i != 0 && i < shnum + 2 && shdr_info[i].idx != 0 in handle_elf()
1597 && shdr_info[i].debug_data == NULL) in handle_elf()
1599 if (shdr_info[i].data == NULL) in handle_elf()
1600 shdr_info[i].data = elf_getdata (shdr_info[i].scn, NULL); in handle_elf()
1601 if (shdr_info[i].data == NULL) in handle_elf()
1604 shdr_info[i].debug_data = shdr_info[i].data; in handle_elf()
1628 bool discard_section = (shdr_info[cnt].idx > 0 in handle_elf()
1629 && shdr_info[cnt].debug_data == NULL in handle_elf()
1630 && shdr_info[cnt].shdr.sh_type != SHT_NOTE in handle_elf()
1631 && shdr_info[cnt].shdr.sh_type != SHT_GROUP in handle_elf()
1635 GElf_Shdr debugshdr = shdr_info[cnt].shdr; in handle_elf()
1644 if (shdr_info[cnt].data == NULL) in handle_elf()
1646 shdr_info[cnt].data = elf_getdata (shdr_info[cnt].scn, NULL); in handle_elf()
1647 if (shdr_info[cnt].data == NULL) in handle_elf()
1658 *debugdata = *shdr_info[cnt].data; in handle_elf()
1661 else if (shdr_info[cnt].debug_data != NULL in handle_elf()
1662 || shdr_info[cnt].shdr.sh_type == SHT_GROUP) in handle_elf()
1665 shdr_info[cnt].debug_data = debugdata; in handle_elf()
1727 shdr_info[0].idx = 0; in handle_elf()
1729 if (shdr_info[cnt].idx > 0) in handle_elf()
1731 shdr_info[cnt].idx = idx++; in handle_elf()
1734 shdr_info[cnt].newscn = elf_newscn (newelf); in handle_elf()
1735 if (shdr_info[cnt].newscn == NULL) in handle_elf()
1743 elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx); in handle_elf()
1746 shdr_info[cnt].se = dwelf_strtab_add (shst, shdr_info[cnt].name); in handle_elf()
1754 && shdr_info[shstrndx].idx == 0)); in handle_elf()
1762 shdr_info[cnt].se = dwelf_strtab_add_len (shst, ".gnu_debuglink", 15); in handle_elf()
1763 shdr_info[cnt].idx = idx++; in handle_elf()
1766 shdr_info[cnt].shdr.sh_type = SHT_PROGBITS; in handle_elf()
1767 shdr_info[cnt].shdr.sh_flags = 0; in handle_elf()
1768 shdr_info[cnt].shdr.sh_addr = 0; in handle_elf()
1769 shdr_info[cnt].shdr.sh_link = SHN_UNDEF; in handle_elf()
1770 shdr_info[cnt].shdr.sh_info = SHN_UNDEF; in handle_elf()
1771 shdr_info[cnt].shdr.sh_entsize = 0; in handle_elf()
1772 shdr_info[cnt].shdr.sh_addralign = 4; in handle_elf()
1776 shdr_info[cnt].shdr.sh_offset = 0; in handle_elf()
1779 shdr_info[cnt].newscn = elf_newscn (newelf); in handle_elf()
1780 if (shdr_info[cnt].newscn == NULL) in handle_elf()
1787 elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx); in handle_elf()
1789 shdr_info[cnt].data = elf_newdata (shdr_info[cnt].newscn); in handle_elf()
1790 if (shdr_info[cnt].data == NULL) in handle_elf()
1802 shdr_info[cnt].data->d_align = 4; in handle_elf()
1803 shdr_info[cnt].shdr.sh_size = shdr_info[cnt].data->d_size in handle_elf()
1805 debuglink_buf = xcalloc (1, shdr_info[cnt].data->d_size); in handle_elf()
1806 shdr_info[cnt].data->d_buf = debuglink_buf; in handle_elf()
1808 strcpy (shdr_info[cnt].data->d_buf, debug_basename); in handle_elf()
1812 debuglink_crc_data = *shdr_info[cnt].data; in handle_elf()
1825 shdr_info[cnt].se = dwelf_strtab_add_len (shst, ".shstrtab", 10); in handle_elf()
1826 shdr_info[cnt].idx = idx; in handle_elf()
1829 shdr_info[cnt].shdr.sh_type = SHT_STRTAB; in handle_elf()
1830 shdr_info[cnt].shdr.sh_flags = 0; in handle_elf()
1831 shdr_info[cnt].shdr.sh_addr = 0; in handle_elf()
1832 shdr_info[cnt].shdr.sh_link = SHN_UNDEF; in handle_elf()
1833 shdr_info[cnt].shdr.sh_info = SHN_UNDEF; in handle_elf()
1834 shdr_info[cnt].shdr.sh_entsize = 0; in handle_elf()
1838 shdr_info[cnt].shdr.sh_offset = 0; in handle_elf()
1839 shdr_info[cnt].shdr.sh_addralign = 1; in handle_elf()
1842 shdr_info[cnt].newscn = elf_newscn (newelf); in handle_elf()
1843 if (shdr_info[cnt].newscn == NULL) in handle_elf()
1850 elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == idx); in handle_elf()
1854 shstrtab_data = elf_newdata (shdr_info[cnt].newscn); in handle_elf()
1870 shdr_info[cnt].shdr.sh_size = shstrtab_data->d_size; in handle_elf()
1875 if (shdr_info[cnt].idx > 0) in handle_elf()
1879 scn = elf_getscn (newelf, shdr_info[cnt].idx); in handle_elf()
1883 shdr_info[cnt].shdr.sh_name = dwelf_strent_off (shdr_info[cnt].se); in handle_elf()
1889 size_t sh_link = shdr_info[cnt].shdr.sh_link; in handle_elf()
1890 if (shdr_info[cnt].shdr.sh_link != 0) in handle_elf()
1891 shdr_info[cnt].shdr.sh_link = in handle_elf()
1892 shdr_info[shdr_info[cnt].shdr.sh_link].idx; in handle_elf()
1894 if (shdr_info[cnt].shdr.sh_type == SHT_GROUP) in handle_elf()
1896 elf_assert (shdr_info[cnt].data != NULL in handle_elf()
1897 && shdr_info[cnt].data->d_buf != NULL); in handle_elf()
1899 Elf32_Word *grpref = (Elf32_Word *) shdr_info[cnt].data->d_buf; in handle_elf()
1903 inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word); in handle_elf()
1906 grpref[inner] = shdr_info[grpref[inner]].idx; in handle_elf()
1912 if (SH_INFO_LINK_P (&shdr_info[cnt].shdr)) in handle_elf()
1913 shdr_info[cnt].shdr.sh_info = in handle_elf()
1914 shdr_info[shdr_info[cnt].shdr.sh_info].idx; in handle_elf()
1920 if (shdr_info[cnt].data == NULL) in handle_elf()
1922 shdr_info[cnt].data = elf_getdata (shdr_info[cnt].scn, NULL); in handle_elf()
1923 if (shdr_info[cnt].data == NULL) in handle_elf()
1933 *newdata = *shdr_info[cnt].data; in handle_elf()
1936 shdr_info[cnt].shdr.sh_size = shdr_info[cnt].data->d_size; in handle_elf()
1940 if (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM in handle_elf()
1941 || shdr_info[cnt].shdr.sh_type == SHT_SYMTAB) in handle_elf()
1948 if (shdr_info[cnt].symtab_idx != 0) in handle_elf()
1950 elf_assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX); in handle_elf()
1953 shndxdata = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn, in handle_elf()
1959 >= shdr_info[cnt].data->d_size / elsize)); in handle_elf()
1962 if (shdr_info[cnt].version_idx != 0) in handle_elf()
1964 elf_assert (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM); in handle_elf()
1968 versiondata = elf_getdata (shdr_info[shdr_info[cnt].version_idx].scn, in handle_elf()
1974 >= shdr_info[cnt].data->d_size / elsize)); in handle_elf()
1977 shdr_info[cnt].newsymidx in handle_elf()
1978 = (Elf32_Word *) xcalloc (shdr_info[cnt].data->d_size in handle_elf()
1985 inner < shdr_info[cnt].data->d_size / elsize; in handle_elf()
1991 GElf_Sym *sym = gelf_getsymshndx (shdr_info[cnt].data, in handle_elf()
2004 && gelf_update_symshndx (shdr_info[cnt].data, in handle_elf()
2010 shdr_info[cnt].newsymidx[inner] = destidx++; in handle_elf()
2016 shdr_info[cnt].shdr.sh_info = destidx - 1; in handle_elf()
2030 sec = shdr_info[sidx].idx; in handle_elf()
2053 gelf_update_symshndx (shdr_info[cnt].data, in handle_elf()
2059 shdr_info[cnt].newsymidx[inner] = destidx++; in handle_elf()
2065 shdr_info[cnt].shdr.sh_info = destidx - 1; in handle_elf()
2068 else if ((shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) != 0 in handle_elf()
2070 && shdr_info[sidx].shdr.sh_type != SHT_GROUP) in handle_elf()
2081 if (gelf_update_sym (shdr_info[cnt].data, destidx, in handle_elf()
2084 shdr_info[cnt].newsymidx[inner] = destidx++; in handle_elf()
2087 && shdr_info[cnt].debug_data == NULL) in handle_elf()
2095 || ((shdr_info[sidx].shdr.sh_type in handle_elf()
2097 && (shdr_info[sidx].shdr.sh_info in handle_elf()
2108 shdr_info[cnt].shdr.sh_size = newdata->d_size in handle_elf()
2115 free (shdr_info[cnt].newsymidx); in handle_elf()
2116 shdr_info[cnt].newsymidx = NULL; in handle_elf()
2125 || (shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) != 0) in handle_elf()
2127 if (shdr_info[cnt].shdr.sh_offset == 0) in handle_elf()
2128 shdr_info[cnt].shdr.sh_offset in handle_elf()
2129 = ((lastoffset + shdr_info[cnt].shdr.sh_addralign - 1) in handle_elf()
2130 & ~((GElf_Off) (shdr_info[cnt].shdr.sh_addralign - 1))); in handle_elf()
2133 if (unlikely (gelf_update_shdr (scn, &shdr_info[cnt].shdr) == 0)) in handle_elf()
2138 GElf_Off filesz = (shdr_info[cnt].shdr.sh_type != SHT_NOBITS in handle_elf()
2139 ? shdr_info[cnt].shdr.sh_size : 0); in handle_elf()
2140 if (lastoffset < shdr_info[cnt].shdr.sh_offset + filesz) in handle_elf()
2141 lastoffset = shdr_info[cnt].shdr.sh_offset + filesz; in handle_elf()
2150 if (shdr_info[cnt].idx > 0) in handle_elf()
2152 scn = elf_getscn (newelf, shdr_info[cnt].idx); in handle_elf()
2153 if ((shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) == 0) in handle_elf()
2155 if (shdr_info[cnt].shdr.sh_offset == 0) in handle_elf()
2156 shdr_info[cnt].shdr.sh_offset in handle_elf()
2157 = ((lastoffset + shdr_info[cnt].shdr.sh_addralign - 1) in handle_elf()
2158 & ~((GElf_Off) (shdr_info[cnt].shdr.sh_addralign - 1))); in handle_elf()
2161 if (unlikely (gelf_update_shdr (scn, &shdr_info[cnt].shdr) == 0)) in handle_elf()
2166 GElf_Off filesz = (shdr_info[cnt].shdr.sh_type != SHT_NOBITS in handle_elf()
2167 ? shdr_info[cnt].shdr.sh_size : 0); in handle_elf()
2168 if (lastoffset < shdr_info[cnt].shdr.sh_offset + filesz) in handle_elf()
2169 lastoffset = shdr_info[cnt].shdr.sh_offset + filesz; in handle_elf()
2178 struct shdr_info *info = &shdr_info[cnt]; in handle_elf()
2187 const Elf32_Word *const newsymidx = shdr_info[symtabidx].newsymidx; in handle_elf()
2196 if (info->idx == 0 && shdr_info[symtabidx].debug_data != NULL) in handle_elf()
2212 const Elf32_Word symidxn = (shdr_info[symtabidx].data->d_size in handle_elf()
2264 shdr_info[symtabidx].idx), in handle_elf()
2278 size_t strshndx = shdr_info[symtabidx].old_sh_link; in handle_elf()
2305 for (size_t inner = shdr_info[symtabidx].shdr.sh_info; in handle_elf()
2337 size_t strshndx = shdr_info[symtabidx].old_sh_link; in handle_elf()
2366 for (size_t inner = shdr_info[symtabidx].shdr.sh_info; in handle_elf()
2401 symd = elf_getdata (elf_getscn (newelf, shdr_info[symtabidx].idx), in handle_elf()
2405 const Elf32_Word syms = (shdr_info[symtabidx].data->d_size / symz); in handle_elf()
2442 const Elf32_Word symn = (shdr_info[symtabidx].data->d_size in handle_elf()
2515 lastsec_offset = shdr_info[shdridx].shdr.sh_offset; in handle_elf()
2516 lastsec_size = shdr_info[shdridx].shdr.sh_size; in handle_elf()
2627 if (shdr_info != NULL) in handle_elf()
2634 free (shdr_info[cnt].newsymidx); in handle_elf()
2635 if (shdr_info[cnt].debug_data != NULL) in handle_elf()
2636 free (shdr_info[cnt].debug_data->d_buf); in handle_elf()
2643 if ((shnum + 2) * sizeof (struct shdr_info) > MAX_STACK_ALLOC) in handle_elf()
2644 free (shdr_info); in handle_elf()