• Home
  • Raw
  • Download

Lines Matching refs:cnt

439   size_t cnt;  in handle_elf()  local
551 for (cnt = 0; cnt < phnum; ++cnt) in handle_elf()
554 GElf_Phdr *phdr = gelf_getphdr (elf, cnt, &phdr_mem); in handle_elf()
556 || unlikely (gelf_update_phdr (newelf, cnt, phdr) == 0)) in handle_elf()
575 for (cnt = 0; cnt < phnum; ++cnt) in handle_elf()
578 GElf_Phdr *phdr = gelf_getphdr (elf, cnt, &phdr_mem); in handle_elf()
580 || unlikely (gelf_update_phdr (debugelf, cnt, phdr) == 0)) in handle_elf()
615 cnt = 1; in handle_elf()
620 elf_assert (elf_ndxscn (scn) == cnt); in handle_elf()
622 shdr_info[cnt].scn = scn; in handle_elf()
625 if (gelf_getshdr (scn, &shdr_info[cnt].shdr) == NULL) in handle_elf()
629 shdr_info[cnt].name = elf_strptr (elf, shstrndx, in handle_elf()
630 shdr_info[cnt].shdr.sh_name); in handle_elf()
631 if (shdr_info[cnt].name == NULL) in handle_elf()
639 shdr_info[cnt].idx = 1; in handle_elf()
642 shdr_info[cnt].old_sh_link = shdr_info[cnt].shdr.sh_link; in handle_elf()
643 if (shdr_info[cnt].old_sh_link >= shnum) in handle_elf()
653 || (shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) == 0) in handle_elf()
654 shdr_info[cnt].shdr.sh_offset = 0; in handle_elf()
658 if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX)) in handle_elf()
660 elf_assert (shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0); in handle_elf()
661 shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx = cnt; in handle_elf()
663 else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GROUP)) in handle_elf()
667 shdr_info[cnt].data = elf_getdata (shdr_info[cnt].scn, NULL); in handle_elf()
668 if (shdr_info[cnt].data == NULL in handle_elf()
669 || shdr_info[cnt].data->d_size < sizeof (Elf32_Word)) in handle_elf()
673 Elf32_Word *grpref = (Elf32_Word *) shdr_info[cnt].data->d_buf; in handle_elf()
676 inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word); in handle_elf()
680 shdr_info[grpref[inner]].group_idx = cnt; in handle_elf()
688 shdr_info[cnt].idx = 0; in handle_elf()
690 shdr_info[cnt].group_cnt = inner - 1; in handle_elf()
692 else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GNU_versym)) in handle_elf()
694 elf_assert (shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0); in handle_elf()
695 shdr_info[shdr_info[cnt].shdr.sh_link].version_idx = cnt; in handle_elf()
700 if ((shdr_info[cnt].shdr.sh_flags & SHF_GROUP) != 0) in handle_elf()
702 elf_assert (shdr_info[cnt].group_idx != 0); in handle_elf()
704 if (shdr_info[shdr_info[cnt].group_idx].idx == 0) in handle_elf()
707 shdr_info[cnt].group_idx = 0; in handle_elf()
708 shdr_info[cnt].shdr.sh_flags &= ~SHF_GROUP; in handle_elf()
713 ++cnt; in handle_elf()
726 for (cnt = 1; cnt < shnum; ++cnt) in handle_elf()
728 if (remove_shdrs ? !(shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) in handle_elf()
729 : ebl_section_strip_p (ebl, ehdr, &shdr_info[cnt].shdr, in handle_elf()
730 shdr_info[cnt].name, remove_comment, in handle_elf()
734 shdr_info[cnt].idx = 0; in handle_elf()
736 idx = shdr_info[cnt].group_idx; in handle_elf()
774 for (cnt = 1; cnt < shnum; ++cnt) in handle_elf()
776 if (shdr_info[cnt].idx == 0) in handle_elf()
780 if (shdr_info[cnt].shdr.sh_type == SHT_REL in handle_elf()
781 || shdr_info[cnt].shdr.sh_type == SHT_RELA) in handle_elf()
783 if (shdr_info[cnt].shdr.sh_info >= shnum) in handle_elf()
785 else if (shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0) in handle_elf()
786 shdr_info[cnt].idx = 1; in handle_elf()
791 if (shdr_info[cnt].shdr.sh_type == SHT_GROUP) in handle_elf()
794 grpref = (Elf32_Word *) shdr_info[cnt].data->d_buf; in handle_elf()
796 in < shdr_info[cnt].data->d_size / sizeof (Elf32_Word); in handle_elf()
802 shdr_info[cnt].idx = 1; in handle_elf()
811 if (shdr_info[cnt].idx == 1) in handle_elf()
817 && shdr_info[cnt].debug_data == NULL in handle_elf()
818 && (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM in handle_elf()
819 || shdr_info[cnt].shdr.sh_type == SHT_SYMTAB)) in handle_elf()
822 if (shdr_info[cnt].data == NULL) in handle_elf()
824 shdr_info[cnt].data in handle_elf()
825 = elf_getdata (shdr_info[cnt].scn, NULL); in handle_elf()
826 if (shdr_info[cnt].data == NULL) in handle_elf()
829 Elf_Data *symdata = shdr_info[cnt].data; in handle_elf()
833 if (shdr_info[cnt].symtab_idx != 0 in handle_elf()
834 && shdr_info[shdr_info[cnt].symtab_idx].data == NULL) in handle_elf()
836 elf_assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB); in handle_elf()
838 shdr_info[shdr_info[cnt].symtab_idx].data in handle_elf()
839 = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn, in handle_elf()
841 if (shdr_info[shdr_info[cnt].symtab_idx].data == NULL) in handle_elf()
845 = shdr_info[shdr_info[cnt].symtab_idx].data; in handle_elf()
852 inner < shdr_info[cnt].data->d_size / elsize; in handle_elf()
882 shdr_info[cnt].debug_data = symdata; in handle_elf()
901 if (shdr_info[shdr_info[cnt].shdr.sh_link].idx == 0) in handle_elf()
903 shdr_info[shdr_info[cnt].shdr.sh_link].idx = 1; in handle_elf()
904 changes |= shdr_info[cnt].shdr.sh_link < cnt; in handle_elf()
908 if (SH_INFO_LINK_P (&shdr_info[cnt].shdr)) in handle_elf()
910 if (shdr_info[cnt].shdr.sh_info >= shnum) in handle_elf()
912 else if ( shdr_info[shdr_info[cnt].shdr.sh_info].idx == 0) in handle_elf()
914 shdr_info[shdr_info[cnt].shdr.sh_info].idx = 1; in handle_elf()
915 changes |= shdr_info[cnt].shdr.sh_info < cnt; in handle_elf()
920 shdr_info[cnt].idx = 2; in handle_elf()
924 && (shdr_info[cnt].idx == 0 || shdr_info[cnt].debug_data != NULL)) in handle_elf()
945 changes |= i < cnt; in handle_elf()
949 check_preserved (shdr_info[cnt].shdr.sh_link); in handle_elf()
950 if (SH_INFO_LINK_P (&shdr_info[cnt].shdr)) in handle_elf()
951 check_preserved (shdr_info[cnt].shdr.sh_info); in handle_elf()
961 for (cnt = 1; cnt < shnum; ++cnt) in handle_elf()
972 bool discard_section = (shdr_info[cnt].idx > 0 in handle_elf()
973 && shdr_info[cnt].debug_data == NULL in handle_elf()
974 && shdr_info[cnt].shdr.sh_type != SHT_NOTE in handle_elf()
975 && shdr_info[cnt].shdr.sh_type != SHT_GROUP in handle_elf()
976 && cnt != ehdr->e_shstrndx); in handle_elf()
979 GElf_Shdr debugshdr = shdr_info[cnt].shdr; in handle_elf()
988 if (shdr_info[cnt].data == NULL) in handle_elf()
990 shdr_info[cnt].data = elf_getdata (shdr_info[cnt].scn, NULL); in handle_elf()
991 if (shdr_info[cnt].data == NULL) in handle_elf()
1002 *debugdata = *shdr_info[cnt].data; in handle_elf()
1005 else if (shdr_info[cnt].debug_data != NULL in handle_elf()
1006 || shdr_info[cnt].shdr.sh_type == SHT_GROUP) in handle_elf()
1009 shdr_info[cnt].debug_data = debugdata; in handle_elf()
1056 for (cnt = idx = 1; cnt < shnum; ++cnt) in handle_elf()
1057 if (shdr_info[cnt].idx > 0) in handle_elf()
1059 shdr_info[cnt].idx = idx++; in handle_elf()
1062 shdr_info[cnt].newscn = elf_newscn (newelf); in handle_elf()
1063 if (shdr_info[cnt].newscn == NULL) in handle_elf()
1071 elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx); in handle_elf()
1074 shdr_info[cnt].se = ebl_strtabadd (shst, shdr_info[cnt].name, 0); in handle_elf()
1078 if (cnt == idx) in handle_elf()
1086 shdr_info[cnt].se = ebl_strtabadd (shst, ".gnu_debuglink", 15); in handle_elf()
1087 shdr_info[cnt].idx = idx++; in handle_elf()
1090 shdr_info[cnt].shdr.sh_type = SHT_PROGBITS; in handle_elf()
1091 shdr_info[cnt].shdr.sh_flags = 0; in handle_elf()
1092 shdr_info[cnt].shdr.sh_addr = 0; in handle_elf()
1093 shdr_info[cnt].shdr.sh_link = SHN_UNDEF; in handle_elf()
1094 shdr_info[cnt].shdr.sh_info = SHN_UNDEF; in handle_elf()
1095 shdr_info[cnt].shdr.sh_entsize = 0; in handle_elf()
1096 shdr_info[cnt].shdr.sh_addralign = 4; in handle_elf()
1100 shdr_info[cnt].shdr.sh_offset = 0; in handle_elf()
1103 shdr_info[cnt].newscn = elf_newscn (newelf); in handle_elf()
1104 if (shdr_info[cnt].newscn == NULL) in handle_elf()
1111 elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx); in handle_elf()
1113 shdr_info[cnt].data = elf_newdata (shdr_info[cnt].newscn); in handle_elf()
1114 if (shdr_info[cnt].data == NULL) in handle_elf()
1126 shdr_info[cnt].data->d_align = 4; in handle_elf()
1127 shdr_info[cnt].shdr.sh_size = shdr_info[cnt].data->d_size in handle_elf()
1129 debuglink_buf = xcalloc (1, shdr_info[cnt].data->d_size); in handle_elf()
1130 shdr_info[cnt].data->d_buf = debuglink_buf; in handle_elf()
1132 strcpy (shdr_info[cnt].data->d_buf, debug_basename); in handle_elf()
1136 debuglink_crc_data = *shdr_info[cnt].data; in handle_elf()
1142 ++cnt; in handle_elf()
1146 shdridx = cnt; in handle_elf()
1149 shdr_info[cnt].se = ebl_strtabadd (shst, ".shstrtab", 10); in handle_elf()
1150 shdr_info[cnt].idx = idx; in handle_elf()
1153 shdr_info[cnt].shdr.sh_type = SHT_STRTAB; in handle_elf()
1154 shdr_info[cnt].shdr.sh_flags = 0; in handle_elf()
1155 shdr_info[cnt].shdr.sh_addr = 0; in handle_elf()
1156 shdr_info[cnt].shdr.sh_link = SHN_UNDEF; in handle_elf()
1157 shdr_info[cnt].shdr.sh_info = SHN_UNDEF; in handle_elf()
1158 shdr_info[cnt].shdr.sh_entsize = 0; in handle_elf()
1162 shdr_info[cnt].shdr.sh_offset = 0; in handle_elf()
1163 shdr_info[cnt].shdr.sh_addralign = 1; in handle_elf()
1166 shdr_info[cnt].newscn = elf_newscn (newelf); in handle_elf()
1167 if (shdr_info[cnt].newscn == NULL) in handle_elf()
1174 elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == idx); in handle_elf()
1178 shstrtab_data = elf_newdata (shdr_info[cnt].newscn); in handle_elf()
1189 shdr_info[cnt].shdr.sh_size = shstrtab_data->d_size; in handle_elf()
1193 for (cnt = 1; cnt <= shdridx; ++cnt) in handle_elf()
1194 if (shdr_info[cnt].idx > 0) in handle_elf()
1198 scn = elf_getscn (newelf, shdr_info[cnt].idx); in handle_elf()
1202 shdr_info[cnt].shdr.sh_name = ebl_strtaboffset (shdr_info[cnt].se); in handle_elf()
1206 if (shdr_info[cnt].shdr.sh_link != 0) in handle_elf()
1207 shdr_info[cnt].shdr.sh_link = in handle_elf()
1208 shdr_info[shdr_info[cnt].shdr.sh_link].idx; in handle_elf()
1210 if (shdr_info[cnt].shdr.sh_type == SHT_GROUP) in handle_elf()
1212 elf_assert (shdr_info[cnt].data != NULL in handle_elf()
1213 && shdr_info[cnt].data->d_buf != NULL); in handle_elf()
1215 Elf32_Word *grpref = (Elf32_Word *) shdr_info[cnt].data->d_buf; in handle_elf()
1217 inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word); in handle_elf()
1226 if (SH_INFO_LINK_P (&shdr_info[cnt].shdr)) in handle_elf()
1227 shdr_info[cnt].shdr.sh_info = in handle_elf()
1228 shdr_info[shdr_info[cnt].shdr.sh_info].idx; in handle_elf()
1232 if (cnt < shnum) in handle_elf()
1234 if (shdr_info[cnt].data == NULL) in handle_elf()
1236 shdr_info[cnt].data = elf_getdata (shdr_info[cnt].scn, NULL); in handle_elf()
1237 if (shdr_info[cnt].data == NULL) in handle_elf()
1247 *newdata = *shdr_info[cnt].data; in handle_elf()
1250 shdr_info[cnt].shdr.sh_size = shdr_info[cnt].data->d_size; in handle_elf()
1254 if (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM in handle_elf()
1255 || shdr_info[cnt].shdr.sh_type == SHT_SYMTAB) in handle_elf()
1262 if (shdr_info[cnt].symtab_idx != 0) in handle_elf()
1264 elf_assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX); in handle_elf()
1267 shndxdata = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn, in handle_elf()
1271 >= shdr_info[cnt].data->d_size / elsize); in handle_elf()
1274 if (shdr_info[cnt].version_idx != 0) in handle_elf()
1276 elf_assert (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM); in handle_elf()
1280 versiondata = elf_getdata (shdr_info[shdr_info[cnt].version_idx].scn, in handle_elf()
1286 >= shdr_info[cnt].data->d_size / elsize)); in handle_elf()
1289 shdr_info[cnt].newsymidx in handle_elf()
1290 = (Elf32_Word *) xcalloc (shdr_info[cnt].data->d_size in handle_elf()
1297 inner < shdr_info[cnt].data->d_size / elsize; in handle_elf()
1303 GElf_Sym *sym = gelf_getsymshndx (shdr_info[cnt].data, in handle_elf()
1316 && gelf_update_symshndx (shdr_info[cnt].data, in handle_elf()
1322 shdr_info[cnt].newsymidx[inner] = destidx++; in handle_elf()
1328 shdr_info[cnt].shdr.sh_info = destidx - 1; in handle_elf()
1367 gelf_update_symshndx (shdr_info[cnt].data, in handle_elf()
1373 shdr_info[cnt].newsymidx[inner] = destidx++; in handle_elf()
1379 shdr_info[cnt].shdr.sh_info = destidx - 1; in handle_elf()
1383 && shdr_info[cnt].debug_data == NULL) in handle_elf()
1402 shdr_info[cnt].shdr.sh_size = newdata->d_size in handle_elf()
1409 free (shdr_info[cnt].newsymidx); in handle_elf()
1410 shdr_info[cnt].newsymidx = NULL; in handle_elf()
1416 if (shdr_info[cnt].shdr.sh_offset == 0) in handle_elf()
1417 shdr_info[cnt].shdr.sh_offset in handle_elf()
1418 = ((lastoffset + shdr_info[cnt].shdr.sh_addralign - 1) in handle_elf()
1419 & ~((GElf_Off) (shdr_info[cnt].shdr.sh_addralign - 1))); in handle_elf()
1422 if (unlikely (gelf_update_shdr (scn, &shdr_info[cnt].shdr) == 0)) in handle_elf()
1427 GElf_Off filesz = (shdr_info[cnt].shdr.sh_type != SHT_NOBITS in handle_elf()
1428 ? shdr_info[cnt].shdr.sh_size : 0); in handle_elf()
1429 if (lastoffset < shdr_info[cnt].shdr.sh_offset + filesz) in handle_elf()
1430 lastoffset = shdr_info[cnt].shdr.sh_offset + filesz; in handle_elf()
1436 for (cnt = 1; cnt <= shdridx; ++cnt) in handle_elf()
1451 cnt), NULL); in handle_elf()
1458 if (shdr_info[cnt].idx == 0 && debug_fname == NULL) in handle_elf()
1464 const Elf32_Word symtabidx = shdr_info[cnt].old_sh_link; in handle_elf()
1467 switch (shdr_info[cnt].shdr.sh_type) in handle_elf()
1478 return (shdr_info[cnt].idx == 0 in handle_elf()
1487 Elf_Data *d = elf_getdata (shdr_info[cnt].idx == 0 in handle_elf()
1488 ? elf_getscn (debugelf, cnt) in handle_elf()
1490 shdr_info[cnt].idx), in handle_elf()
1493 && shdr_info[cnt].shdr.sh_entsize != 0); in handle_elf()
1494 size_t nrels = (shdr_info[cnt].shdr.sh_size in handle_elf()
1495 / shdr_info[cnt].shdr.sh_entsize); in handle_elf()
1500 if (shdr_info[cnt].shdr.sh_type == SHT_REL) in handle_elf()
1546 elf_assert (shdr_info[cnt].idx > 0); in handle_elf()
1549 scn = elf_getscn (newelf, shdr_info[cnt].idx); in handle_elf()
1561 if (shdr_info[cnt].shdr.sh_entsize == sizeof (Elf32_Word)) in handle_elf()
1622 elf_assert (shdr_info[cnt].shdr.sh_entsize in handle_elf()
1688 elf_assert (shdr_info[cnt].idx > 0); in handle_elf()
1691 scn = elf_getscn (newelf, shdr_info[cnt].idx); in handle_elf()
1732 scn = elf_getscn (newelf, shdr_info[cnt].idx); in handle_elf()
1754 cnt = 0; in handle_elf()
1757 cnt++; in handle_elf()
2153 for (cnt = 1; cnt <= shdridx; ++cnt) in handle_elf()
2155 free (shdr_info[cnt].newsymidx); in handle_elf()
2156 if (shdr_info[cnt].debug_data != NULL) in handle_elf()
2157 free (shdr_info[cnt].debug_data->d_buf); in handle_elf()