Home | History | Annotate | Download | only in src

Lines Matching refs:cnt

393   size_t cnt;
489 for (cnt = 0; cnt < ehdr->e_phnum; ++cnt)
494 phdr = gelf_getphdr (elf, cnt, &phdr_mem);
496 || unlikely (gelf_update_phdr (newelf, cnt, phdr) == 0))
515 for (cnt = 0; cnt < ehdr->e_phnum; ++cnt)
520 phdr = gelf_getphdr (elf, cnt, &phdr_mem);
522 || unlikely (gelf_update_phdr (debugelf, cnt, phdr) == 0))
551 cnt = 1;
556 assert (elf_ndxscn (scn) == cnt);
558 shdr_info[cnt].scn = scn;
561 if (gelf_getshdr (scn, &shdr_info[cnt].shdr) == NULL)
565 shdr_info[cnt].name = elf_strptr (elf, shstrndx,
566 shdr_info[cnt].shdr.sh_name);
567 if (shdr_info[cnt].name == NULL)
574 shdr_info[cnt].idx = 1;
577 shdr_info[cnt].old_sh_link = shdr_info[cnt].shdr.sh_link;
583 || (shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) == 0)
584 shdr_info[cnt].shdr.sh_offset = 0;
588 if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX))
590 assert (shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0);
591 shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx = cnt;
593 else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GROUP))
600 shdr_info[cnt].data = elf_getdata (shdr_info[cnt].scn, NULL);
601 if (shdr_info[cnt].data == NULL)
605 grpref = (Elf32_Word *) shdr_info[cnt].data->d_buf;
607 inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word);
609 shdr_info[grpref[inner]].group_idx = cnt;
614 shdr_info[cnt].idx = 0;
616 shdr_info[cnt].group_cnt = inner - 1;
618 else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GNU_versym))
620 assert (shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0);
621 shdr_info[shdr_info[cnt].shdr.sh_link].version_idx = cnt;
626 if ((shdr_info[cnt].shdr.sh_flags & SHF_GROUP) != 0)
628 assert (shdr_info[cnt].group_idx != 0);
630 if (shdr_info[shdr_info[cnt].group_idx].idx == 0)
633 shdr_info[cnt].group_idx = 0;
634 shdr_info[cnt].shdr.sh_flags &= ~SHF_GROUP;
639 ++cnt;
652 for (cnt = 1; cnt < shnum; ++cnt)
654 if (SECTION_STRIP_P (ebl, elf, ehdr, &shdr_info[cnt].shdr,
655 shdr_info[cnt].name, remove_comment, remove_debug))
658 shdr_info[cnt].idx = 0;
660 idx = shdr_info[cnt].group_idx;
698 for (cnt = 1; cnt < shnum; ++cnt)
700 if (shdr_info[cnt].idx == 0)
704 if ((shdr_info[cnt].shdr.sh_type == SHT_REL
705 || shdr_info[cnt].shdr.sh_type == SHT_RELA)
706 && shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0)
707 shdr_info[cnt].idx = 1;
710 if (shdr_info[cnt].idx == 1)
715 if (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM
716 || shdr_info[cnt].shdr.sh_type == SHT_SYMTAB)
723 if (shdr_info[cnt].data == NULL)
725 shdr_info[cnt].data
726 = elf_getdata (shdr_info[cnt].scn, NULL);
727 if (shdr_info[cnt].data == NULL)
730 symdata = shdr_info[cnt].data;
734 if (shdr_info[cnt].symtab_idx != 0
735 && shdr_info[shdr_info[cnt].symtab_idx].data == NULL)
737 assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB);
739 shdr_info[shdr_info[cnt].symtab_idx].data
740 = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn,
742 if (shdr_info[shdr_info[cnt].symtab_idx].data == NULL)
745 xndxdata = shdr_info[shdr_info[cnt].symtab_idx].data;
752 inner < shdr_info[cnt].data->d_size / elsize;
781 changes |= scnidx < cnt;
801 if (shdr_info[shdr_info[cnt].shdr.sh_link].idx == 0)
803 shdr_info[shdr_info[cnt].shdr.sh_link].idx = 1;
804 changes |= shdr_info[cnt].shdr.sh_link < cnt;
808 if (SH_INFO_LINK_P (&shdr_info[cnt].shdr)
809 && shdr_info[shdr_info[cnt].shdr.sh_info].idx == 0)
811 shdr_info[shdr_info[cnt].shdr.sh_info].idx = 1;
812 changes |= shdr_info[cnt].shdr.sh_info < cnt;
816 shdr_info[cnt].idx = 2;
826 for (cnt = 1; cnt < shnum; ++cnt)
838 discard_section = shdr_info[cnt].idx > 0 && cnt != ehdr->e_shstrndx;
841 debugshdr = shdr_info[cnt].shdr;
850 if (shdr_info[cnt].data == NULL)
852 shdr_info[cnt].data = elf_getdata (shdr_info[cnt].scn, NULL);
853 if (shdr_info[cnt].data == NULL)
863 *debugdata = *shdr_info[cnt].data;
936 for (cnt = idx = 1; cnt < shnum; ++cnt)
937 if (shdr_info[cnt].idx > 0)
939 shdr_info[cnt].idx = idx++;
942 shdr_info[cnt].newscn = elf_newscn (newelf);
943 if (shdr_info[cnt].newscn == NULL)
947 assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx);
950 shdr_info[cnt].se = ebl_strtabadd (shst, shdr_info[cnt].name, 0);
954 if (cnt == idx)
965 shdr_info[cnt].se = ebl_strtabadd (shst, ".gnu_debuglink", 15);
966 shdr_info[cnt].idx = idx++;
969 shdr_info[cnt].shdr.sh_type = SHT_PROGBITS;
970 shdr_info[cnt].shdr.sh_flags = 0;
971 shdr_info[cnt].shdr.sh_addr = 0;
972 shdr_info[cnt].shdr.sh_link = SHN_UNDEF;
973 shdr_info[cnt].shdr.sh_info = SHN_UNDEF;
974 shdr_info[cnt].shdr.sh_entsize = 0;
975 shdr_info[cnt].shdr.sh_addralign = 4;
979 shdr_info[cnt].shdr.sh_offset = 0;
982 shdr_info[cnt].newscn = elf_newscn (newelf);
983 if (shdr_info[cnt].newscn == NULL)
987 assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx);
989 shdr_info[cnt].data = elf_newdata (shdr_info[cnt].newscn);
990 if (shdr_info[cnt].data == NULL)
999 shdr_info[cnt].data->d_align = 4;
1000 shdr_info[cnt].shdr.sh_size = shdr_info[cnt].data->d_size
1002 shdr_info[cnt].data->d_buf = xcalloc (1, shdr_info[cnt].data->d_size);
1004 strcpy (shdr_info[cnt].data->d_buf, debug_basename);
1011 memcpy ((char *)shdr_info[cnt].data->d_buf + crc_offset,
1015 ++cnt;
1019 size_t shdridx = cnt;
1022 shdr_info[cnt].se = ebl_strtabadd (shst, ".shstrtab", 10);
1023 shdr_info[cnt].idx = idx;
1026 shdr_info[cnt].shdr.sh_type = SHT_STRTAB;
1027 shdr_info[cnt].shdr.sh_flags = 0;
1028 shdr_info[cnt].shdr.sh_addr = 0;
1029 shdr_info[cnt].shdr.sh_link = SHN_UNDEF;
1030 shdr_info[cnt].shdr.sh_info = SHN_UNDEF;
1031 shdr_info[cnt].shdr.sh_entsize = 0;
1035 shdr_info[cnt].shdr.sh_offset = 0;
1036 shdr_info[cnt].shdr.sh_addralign = 1;
1039 shdr_info[cnt].newscn = elf_newscn (newelf);
1040 if (shdr_info[cnt].newscn == NULL)
1044 assert (elf_ndxscn (shdr_info[cnt].newscn) == idx);
1048 shstrtab_data = elf_newdata (shdr_info[cnt].newscn);
1056 shdr_info[cnt].shdr.sh_size = shstrtab_data->d_size;
1060 for (cnt = 1; cnt <= shdridx; ++cnt)
1061 if (shdr_info[cnt].idx > 0)
1065 scn = elf_getscn (newelf, shdr_info[cnt].idx);
1069 shdr_info[cnt].shdr.sh_name = ebl_strtaboffset (shdr_info[cnt].se);
1073 if (shdr_info[cnt].shdr.sh_link != 0)
1074 shdr_info[cnt].shdr.sh_link =
1075 shdr_info[shdr_info[cnt].shdr.sh_link].idx;
1077 if (shdr_info[cnt].shdr.sh_type == SHT_GROUP)
1079 assert (shdr_info[cnt].data != NULL);
1081 Elf32_Word *grpref = (Elf32_Word *) shdr_info[cnt].data->d_buf;
1083 inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word);
1089 if (SH_INFO_LINK_P (&shdr_info[cnt].shdr))
1090 shdr_info[cnt].shdr.sh_info =
1091 shdr_info[shdr_info[cnt].shdr.sh_info].idx;
1095 if (cnt < shnum)
1097 if (shdr_info[cnt].data == NULL)
1099 shdr_info[cnt].data = elf_getdata (shdr_info[cnt].scn, NULL);
1100 if (shdr_info[cnt].data == NULL)
1110 *newdata = *shdr_info[cnt].data;
1113 shdr_info[cnt].shdr.sh_size = shdr_info[cnt].data->d_size;
1117 if (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM
1118 || shdr_info[cnt].shdr.sh_type == SHT_SYMTAB)
1126 if (shdr_info[cnt].symtab_idx != 0)
1128 assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX);
1131 shndxdata = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn,
1135 >= shdr_info[cnt].data->d_size / elsize);
1138 if (shdr_info[cnt].version_idx != 0)
1140 assert (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM);
1144 versiondata = elf_getdata (shdr_info[shdr_info[cnt].version_idx].scn,
1148 >= shdr_info[cnt].data->d_size / elsize);
1151 shdr_info[cnt].newsymidx
1152 = (Elf32_Word *) xcalloc (shdr_info[cnt].data->d_size
1159 inner < shdr_info[cnt].data->d_size / elsize;
1165 GElf_Sym *sym = gelf_getsymshndx (shdr_info[cnt].data,
1178 && gelf_update_symshndx (shdr_info[cnt].data,
1184 shdr_info[cnt].newsymidx[inner] = destidx++;
1190 shdr_info[cnt].shdr.sh_info = destidx - 1;
1228 gelf_update_symshndx (shdr_info[cnt].data,
1234 shdr_info[cnt].newsymidx[inner] = destidx++;
1240 shdr_info[cnt].shdr.sh_info = destidx - 1;
1252 shdr_info[cnt].shdr.sh_size = newdata->d_size
1259 free (shdr_info[cnt].newsymidx);
1260 shdr_info[cnt].newsymidx = NULL;
1266 if (shdr_info[cnt].shdr.sh_offset == 0)
1267 shdr_info[cnt].shdr.sh_offset
1268 = ((lastoffset + shdr_info[cnt].shdr.sh_addralign - 1)
1269 & ~((GElf_Off) (shdr_info[cnt].shdr.sh_addralign - 1)));
1272 if (unlikely (gelf_update_shdr (scn, &shdr_info[cnt].shdr) == 0))
1277 GElf_Off filesz = (shdr_info[cnt].shdr.sh_type != SHT_NOBITS
1278 ? shdr_info[cnt].shdr.sh_size : 0);
1279 if (lastoffset < shdr_info[cnt].shdr.sh_offset + filesz)
1280 lastoffset = shdr_info[cnt].shdr.sh_offset + filesz;
1288 for (cnt = 1; cnt <= shdridx; ++cnt)
1290 if (shdr_info[cnt].idx == 0)
1294 if (shdr_info[cnt].shdr.sh_type == SHT_REL
1295 || shdr_info[cnt].shdr.sh_type == SHT_RELA)
1298 if (shdr_info[shdr_info[cnt].old_sh_link].newsymidx == NULL)
1302 = shdr_info[shdr_info[cnt].old_sh_link].newsymidx;
1304 shdr_info[cnt].idx),
1307 size_t nrels = (shdr_info[cnt].shdr.sh_size
1308 / shdr_info[cnt].shdr.sh_entsize);
1310 if (shdr_info[cnt].shdr.sh_type == SHT_REL)
1347 else if (shdr_info[cnt].shdr.sh_type == SHT_HASH)
1350 Elf32_Word symtabidx = shdr_info[cnt].old_sh_link;
1358 scn = elf_getscn (newelf, shdr_info[cnt].idx);
1370 if (shdr_info[cnt].shdr.sh_entsize == sizeof (Elf32_Word))
1433 assert (shdr_info[cnt].shdr.sh_entsize
1500 else if (shdr_info[cnt].shdr.sh_type == SHT_GNU_versym)
1504 Elf32_Word symtabidx = shdr_info[cnt].old_sh_link;
1512 scn = elf_getscn (newelf, shdr_info[cnt].idx);
1562 else if (shdr_info[cnt].shdr.sh_type == SHT_GROUP)
1565 if (shdr_info[shdr_info[cnt].old_sh_link].newsymidx != NULL)
1569 scn = elf_getscn (newelf, shdr_info[cnt].idx);
1574 size_t stabidx = shdr_info[cnt].old_sh_link;
1655 for (cnt = 1; cnt <= shdridx; ++cnt)
1656 free (shdr_info[cnt].newsymidx);