Home | History | Annotate | Download | only in src

Lines Matching refs:cnt

406   size_t cnt;
504 for (cnt = 0; cnt < ehdr->e_phnum; ++cnt)
507 GElf_Phdr *phdr = gelf_getphdr (elf, cnt, &phdr_mem);
509 || unlikely (gelf_update_phdr (newelf, cnt, phdr) == 0))
528 for (cnt = 0; cnt < ehdr->e_phnum; ++cnt)
531 GElf_Phdr *phdr = gelf_getphdr (elf, cnt, &phdr_mem);
533 || unlikely (gelf_update_phdr (debugelf, cnt, phdr) == 0))
563 cnt = 1;
568 assert (elf_ndxscn (scn) == cnt);
570 shdr_info[cnt].scn = scn;
573 cnt].shdr) == NULL)
577 shdr_info[cnt].name = elf_strptr (elf, shstrndx,
578 shdr_info[cnt].shdr.sh_name);
579 if (shdr_info[cnt].name == NULL)
586 shdr_info[cnt].idx = 1;
589 shdr_info[cnt].old_sh_link = shdr_info[cnt].shdr.sh_link;
595 || (shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) == 0)
596 shdr_info[cnt].shdr.sh_offset = 0;
600 if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX))
602 assert (shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0);
603 shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx = cnt;
605 else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GROUP))
609 shdr_info[cnt].data = elf_getdata (shdr_info[cnt].scn, NULL);
610 if (shdr_info[cnt].data == NULL)
614 Elf32_Word *grpref = (Elf32_Word *) shdr_info[cnt].data->d_buf;
617 inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word);
619 shdr_info[grpref[inner]].group_idx = cnt;
624 shdr_info[cnt].idx = 0;
626 shdr_info[cnt].group_cnt = inner - 1;
628 else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GNU_versym))
630 assert (shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0);
631 shdr_info[shdr_info[cnt].shdr.sh_link].version_idx = cnt;
636 if ((shdr_info[cnt].shdr.sh_flags & SHF_GROUP) != 0)
638 assert (shdr_info[cnt].group_idx != 0);
640 if (shdr_info[shdr_info[cnt].group_idx].idx == 0)
643 shdr_info[cnt].group_idx = 0;
644 shdr_info[cnt].shdr.sh_flags &= ~SHF_GROUP;
649 ++cnt;
662 for (cnt = 1; cnt < shnum; ++cnt)
664 if (ebl_section_strip_p (ebl, ehdr, &shdr_info[cnt].shdr,
665 shdr_info[cnt].name, remove_comment,
669 shdr_info[cnt].idx = 0;
671 idx = shdr_info[cnt].group_idx;
707 for (cnt = 1; cnt < shnum; ++cnt)
709 if (shdr_info[cnt].idx == 0)
713 if ((shdr_info[cnt].shdr.sh_type == SHT_REL
714 || shdr_info[cnt].shdr.sh_type == SHT_RELA)
715 && shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0)
716 shdr_info[cnt].idx = 1;
719 if (shdr_info[cnt].idx == 1)
725 && shdr_info[cnt].debug_data == NULL
726 && (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM
727 || shdr_info[cnt].shdr.sh_type == SHT_SYMTAB))
730 if (shdr_info[cnt].data == NULL)
732 shdr_info[cnt].data
733 = elf_getdata (shdr_info[cnt].scn, NULL);
734 if (shdr_info[cnt].data == NULL)
737 Elf_Data *symdata = shdr_info[cnt].data;
741 if (shdr_info[cnt].symtab_idx != 0
742 && shdr_info[shdr_info[cnt].symtab_idx].data == NULL)
744 assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB);
746 shdr_info[shdr_info[cnt].symtab_idx].data
747 = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn,
749 if (shdr_info[shdr_info[cnt].symtab_idx].data == NULL)
753 = shdr_info[shdr_info[cnt].symtab_idx].data;
761 inner < shdr_info[cnt].data->d_size / elsize;
788 shdr_info[cnt].debug_data = symdata;
807 if (shdr_info[shdr_info[cnt].shdr.sh_link].idx == 0)
809 shdr_info[shdr_info[cnt].shdr.sh_link].idx = 1;
810 changes |= shdr_info[cnt].shdr.sh_link < cnt;
814 if (SH_INFO_LINK_P (&shdr_info[cnt].shdr)
815 && shdr_info[shdr_info[cnt].shdr.sh_info].idx == 0)
817 shdr_info[shdr_info[cnt].shdr.sh_info].idx = 1;
818 changes |= shdr_info[cnt].shdr.sh_info < cnt;
822 shdr_info[cnt].idx = 2;
826 && (shdr_info[cnt].idx == 0 || shdr_info[cnt].debug_data != NULL))
846 changes |= i < cnt;
850 check_preserved (shdr_info[cnt].shdr.sh_link);
851 if (SH_INFO_LINK_P (&shdr_info[cnt].shdr))
852 check_preserved (shdr_info[cnt].shdr.sh_info);
862 for (cnt = 1; cnt < shnum; ++cnt)
870 bool discard_section = (shdr_info[cnt].idx > 0
871 && shdr_info[cnt].debug_data == NULL
872 && shdr_info[cnt].shdr.sh_type != SHT_NOTE
873 && cnt != ehdr->e_shstrndx);
876 GElf_Shdr debugshdr = shdr_info[cnt].shdr;
885 if (shdr_info[cnt].data == NULL)
887 shdr_info[cnt].data = elf_getdata (shdr_info[cnt].scn, NULL);
888 if (shdr_info[cnt].data == NULL)
899 *debugdata = *shdr_info[cnt].data;
902 else if (shdr_info[cnt].debug_data != NULL)
905 shdr_info[cnt].debug_data = debugdata;
946 for (cnt = idx = 1; cnt < shnum; ++cnt)
947 if (shdr_info[cnt].idx > 0)
949 shdr_info[cnt].idx = idx++;
952 shdr_info[cnt].newscn = elf_newscn (newelf);
953 if (shdr_info[cnt].newscn == NULL)
957 assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx);
960 shdr_info[cnt].se = ebl_strtabadd (shst, shdr_info[cnt].name, 0);
964 if (cnt == idx)
972 shdr_info[cnt].se = ebl_strtabadd (shst, ".gnu_debuglink", 15);
973 shdr_info[cnt].idx = idx++;
976 shdr_info[cnt].shdr.sh_type = SHT_PROGBITS;
977 shdr_info[cnt].shdr.sh_flags = 0;
978 shdr_info[cnt].shdr.sh_addr = 0;
979 shdr_info[cnt].shdr.sh_link = SHN_UNDEF;
980 shdr_info[cnt].shdr.sh_info = SHN_UNDEF;
981 shdr_info[cnt].shdr.sh_entsize = 0;
982 shdr_info[cnt].shdr.sh_addralign = 4;
986 shdr_info[cnt].shdr.sh_offset = 0;
989 shdr_info[cnt].newscn = elf_newscn (newelf);
990 if (shdr_info[cnt].newscn == NULL)
994 assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx);
996 shdr_info[cnt].data = elf_newdata (shdr_info[cnt].newscn);
997 if (shdr_info[cnt].data == NULL)
1006 shdr_info[cnt].data->d_align = 4;
1007 shdr_info[cnt].shdr.sh_size = shdr_info[cnt].data->d_size
1009 shdr_info[cnt].data->d_buf = xcalloc (1, shdr_info[cnt].data->d_size);
1011 strcpy (shdr_info[cnt].data->d_buf, debug_basename);
1015 debuglink_crc_data = *shdr_info[cnt].data;
1021 ++cnt;
1025 shdridx = cnt;
1028 shdr_info[cnt].se = ebl_strtabadd (shst, ".shstrtab", 10);
1029 shdr_info[cnt].idx = idx;
1032 shdr_info[cnt].shdr.sh_type = SHT_STRTAB;
1033 shdr_info[cnt].shdr.sh_flags = 0;
1034 shdr_info[cnt].shdr.sh_addr = 0;
1035 shdr_info[cnt].shdr.sh_link = SHN_UNDEF;
1036 shdr_info[cnt].shdr.sh_info = SHN_UNDEF;
1037 shdr_info[cnt].shdr.sh_entsize = 0;
1041 shdr_info[cnt].shdr.sh_offset = 0;
1042 shdr_info[cnt].shdr.sh_addralign = 1;
1045 shdr_info[cnt].newscn = elf_newscn (newelf);
1046 if (shdr_info[cnt].newscn == NULL)
1050 assert (elf_ndxscn (shdr_info[cnt].newscn) == idx);
1054 shstrtab_data = elf_newdata (shdr_info[cnt].newscn);
1062 shdr_info[cnt].shdr.sh_size = shstrtab_data->d_size;
1066 for (cnt = 1; cnt <= shdridx; ++cnt)
1067 if (shdr_info[cnt].idx > 0)
1071 scn = elf_getscn (newelf, shdr_info[cnt].idx);
1075 shdr_info[cnt].shdr.sh_name = ebl_strtaboffset (shdr_info[cnt].se);
1079 if (shdr_info[cnt].shdr.sh_link != 0)
1080 shdr_info[cnt].shdr.sh_link =
1081 shdr_info[shdr_info[cnt].shdr.sh_link].idx;
1083 if (shdr_info[cnt].shdr.sh_type == SHT_GROUP)
1085 assert (shdr_info[cnt].data != NULL);
1087 Elf32_Word *grpref = (Elf32_Word *) shdr_info[cnt].data->d_buf;
1089 inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word);
1095 if (SH_INFO_LINK_P (&shdr_info[cnt].shdr))
1096 shdr_info[cnt].shdr.sh_info =
1097 shdr_info[shdr_info[cnt].shdr.sh_info].idx;
1101 if (cnt < shnum)
1103 if (shdr_info[cnt].data == NULL)
1105 shdr_info[cnt].data = elf_getdata (shdr_info[cnt].scn, NULL);
1106 if (shdr_info[cnt].data == NULL)
1116 *newdata = *shdr_info[cnt].data;
1119 shdr_info[cnt].shdr.sh_size = shdr_info[cnt].data->d_size;
1123 if (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM
1124 || shdr_info[cnt].shdr.sh_type == SHT_SYMTAB)
1132 if (shdr_info[cnt].symtab_idx != 0)
1134 assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX);
1137 shndxdata = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn,
1141 >= shdr_info[cnt].data->d_size / elsize);
1144 if (shdr_info[cnt].version_idx != 0)
1146 assert (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM);
1150 versiondata = elf_getdata (shdr_info[shdr_info[cnt].version_idx].scn,
1154 >= shdr_info[cnt].data->d_size / elsize);
1157 shdr_info[cnt].newsymidx
1158 = (Elf32_Word *) xcalloc (shdr_info[cnt].data->d_size
1165 inner < shdr_info[cnt].data->d_size / elsize;
1171 GElf_Sym *sym = gelf_getsymshndx (shdr_info[cnt].data,
1184 && gelf_update_symshndx (shdr_info[cnt].data,
1190 shdr_info[cnt].newsymidx[inner] = destidx++;
1196 shdr_info[cnt].shdr.sh_info = destidx - 1;
1234 gelf_update_symshndx (shdr_info[cnt].data,
1240 shdr_info[cnt].newsymidx[inner] = destidx++;
1246 shdr_info[cnt].shdr.sh_info = destidx - 1;
1250 || shdr_info[cnt].debug_data == NULL)
1259 shdr_info[cnt].shdr.sh_size = newdata->d_size
1266 free (shdr_info[cnt].newsymidx);
1267 shdr_info[cnt].newsymidx = NULL;
1273 if (shdr_info[cnt].shdr.sh_offset == 0)
1274 shdr_info[cnt].shdr.sh_offset
1275 = ((lastoffset + shdr_info[cnt].shdr.sh_addralign - 1)
1276 & ~((GElf_Off) (shdr_info[cnt].shdr.sh_addralign - 1)));
1279 if (unlikely (gelf_update_shdr (scn, &shdr_info[cnt].shdr) == 0))
1284 GElf_Off filesz = (shdr_info[cnt].shdr.sh_type != SHT_NOBITS
1285 ? shdr_info[cnt].shdr.sh_size : 0);
1286 if (lastoffset < shdr_info[cnt].shdr.sh_offset + filesz)
1287 lastoffset = shdr_info[cnt].shdr.sh_offset + filesz;
1293 for (cnt = 1; cnt <= shdridx; ++cnt)
1308 cnt), NULL);
1313 if (shdr_info[cnt].idx == 0 && debug_fname == NULL)
1319 const Elf32_Word symtabidx = shdr_info[cnt].old_sh_link;
1321 switch (shdr_info[cnt].shdr.sh_type)
1332 return (shdr_info[cnt].idx == 0
1341 Elf_Data *d = elf_getdata (shdr_info[cnt].idx == 0
1342 ? elf_getscn (debugelf, cnt)
1344 shdr_info[cnt].idx),
1347 size_t nrels = (shdr_info[cnt].shdr.sh_size
1348 / shdr_info[cnt].shdr.sh_entsize);
1350 if (shdr_info[cnt].shdr.sh_type == SHT_REL)
1394 assert (shdr_info[cnt].idx > 0);
1397 scn = elf_getscn (newelf, shdr_info[cnt].idx);
1409 if (shdr_info[cnt].shdr.sh_entsize == sizeof (Elf32_Word))
1463 assert (shdr_info[cnt].shdr.sh_entsize
1521 assert (shdr_info[cnt].idx > 0);
1524 scn = elf_getscn (newelf, shdr_info[cnt].idx);
1563 scn = elf_getscn (newelf, shdr_info[cnt].idx);
1699 for (cnt = 1; cnt <= shdridx; ++cnt)
1701 free (shdr_info[cnt].newsymidx);
1702 if (shdr_info[cnt].debug_data != NULL)
1703 free (shdr_info[cnt].debug_data->d_buf);