Lines Matching refs:sec
773 * sec - Section to be processed (SINFO_T_VERDEF or SINFO_T_VERNEED).
776 * On success, sec->size is set to the section size in bytes, and
780 verdefneed_size(FSTATE *fstate, SINFO *sec)
788 size_t num_main = sec->vercnt;
797 if (sec->type == SINFO_T_VERDEF) {
818 offset = highwater = map_addr_to_offset(fstate, sec->vaddr,
822 sec->size = offset;
849 sec->size = highwater - sec->size;
861 * sec - Section information
867 * On failure, an error is reported, all resources used by sec
868 * are released, and sec->type is set to SINFO_T_NULL, effectively
873 get_data(FSTATE *fstate, SINFO *sec)
884 if ((sec->type == SINFO_T_NULL) || (sec->shdr != NULL))
887 if (((sec->shdr = malloc(sizeof (*sec->shdr))) == NULL) ||
888 ((sec->data = malloc(sizeof (*sec->data))) == NULL)) {
890 sinfo_free(sec, 1);
895 tinfo = &sinfo_data[sec->type];
907 sec->shdr->sh_name = 0;
908 sec->shdr->sh_type = tinfo->sh_type;
909 sec->shdr->sh_flags = tinfo->sh_flags;
915 sec->shdr->sh_addr = sec->vaddr;
916 sec->shdr->sh_offset = sec->offset;
918 } else if (sec->vaddr == 0) {
924 sec->shdr->sh_addr = map_offset_to_addr(fstate, sec->offset,
925 sec->size, &zero_bytes, &phdr);
926 sec->shdr->sh_offset = sec->offset;
932 sec->shdr->sh_addr = sec->vaddr;
933 sec->shdr->sh_offset = map_addr_to_offset(fstate,
934 sec->vaddr, sec->size, &zero_bytes, &phdr);
936 if (sec->shdr->sh_offset == 0) {
937 sinfo_free(sec, 1);
945 sec->shdr->sh_flags |= SHF_WRITE;
946 sec->shdr->sh_size = sec->size;
947 sec->shdr->sh_link = 0;
948 sec->shdr->sh_info = 0;
949 sec->shdr->sh_addralign = tinfo->sh_addralign;
950 sec->shdr->sh_entsize = tinfo->sh_entsize;
957 sec->shdr->sh_link = SINFO_T_DYNSTR;
961 sec->shdr->sh_link = SINFO_T_DYNSTR;
962 sec->shdr->sh_info = 1; /* First global symbol */
966 sec->shdr->sh_link = SINFO_T_DYNSTR;
971 sec->shdr->sh_info = sec->shdr->sh_size / sizeof (Sym);
979 sec->shdr->sh_link = SINFO_T_DYNSYM;
984 sec->shdr->sh_link = SINFO_T_DYNSTR;
985 sec->shdr->sh_info = sec->vercnt;
989 sec->shdr->sh_link = SINFO_T_DYNSYM;
990 sec->shdr->sh_info = SINFO_T_DYN;
995 sec->shdr->sh_link = SINFO_T_LDYNSYM;
1002 sec->data->d_type = tinfo->libelf_type;
1003 sec->data->d_size = sec->size;
1004 sec->data->d_off = 0;
1005 sec->data->d_align = tinfo->sh_addralign;
1006 sec->data->d_version = fstate->ehdr->e_version;
1008 if (sec->size == 0) {
1009 sec->data->d_buf = NULL;
1013 if ((sec->data->d_buf = malloc(sec->size)) == NULL) {
1016 sinfo_free(sec, 1);
1022 read_bytes = sec->size - zero_bytes;
1024 (read_data(fstate, sec->shdr->sh_offset, sec->data->d_buf,
1026 sinfo_free(sec, 1);
1030 bzero(read_bytes + (char *)sec->data->d_buf, zero_bytes);
1033 (elf_xlatetom(sec->data, sec->data,
1035 sinfo_free(sec, 1);
1113 } sec;
1114 static const size_t sinfo_n = sizeof (sec) / sizeof (sec.dyn);
1115 SINFO *secarr = (SINFO *) &sec;
1146 bzero(&sec, sizeof (sec)); /* Initialize "by-name" sec info */
1170 sec.dyn.type = SINFO_T_DYN;
1171 sinfo = &sec.dyn;
1175 sec.interp.type = SINFO_T_INTERP;
1176 sinfo = &sec.interp;
1188 sec.unwind.type = SINFO_T_UNWIND;
1189 sinfo = &sec.unwind;
1193 sec.cap.type = SINFO_T_CAP;
1194 sinfo = &sec.cap;
1212 if (sec.dyn.type == SINFO_T_DYN)
1213 (void) get_data(&fstate, &sec.dyn);
1214 if ((sec.dyn.type == SINFO_T_DYN) && (sec.dyn.data->d_buf != NULL)) {
1216 for (dyn = sec.dyn.data->d_buf; dyn->d_tag != DT_NULL; dyn++) {
1219 sec.hash.type = SINFO_T_HASH;
1220 sec.hash.vaddr = dyn->d_un.d_ptr;
1224 sec.dynstr.type = SINFO_T_DYNSTR;
1225 sec.dynstr.vaddr = dyn->d_un.d_ptr;
1229 sec.dynsym.type = SINFO_T_DYNSYM;
1230 sec.dynsym.vaddr = dyn->d_un.d_ptr;
1234 sec.rela.type = SINFO_T_RELA;
1235 sec.rela.vaddr = dyn->d_un.d_ptr;
1239 sec.rela.size = dyn->d_un.d_val;
1243 sec.dynstr.size = dyn->d_un.d_val;
1247 sec.rel.type = SINFO_T_REL;
1248 sec.rel.vaddr = dyn->d_un.d_ptr;
1252 sec.rel.size = dyn->d_un.d_val;
1256 sec.initarr.type = SINFO_T_INITARR;
1257 sec.initarr.vaddr = dyn->d_un.d_ptr;
1261 sec.initarr.size = dyn->d_un.d_val;
1265 sec.finiarr.type = SINFO_T_FINIARR;
1266 sec.finiarr.vaddr = dyn->d_un.d_ptr;
1270 sec.finiarr.size = dyn->d_un.d_val;
1274 sec.preinitarr.type = SINFO_T_PREINITARR;
1275 sec.preinitarr.vaddr = dyn->d_un.d_ptr;
1279 sec.preinitarr.size = dyn->d_un.d_val;
1283 sec.capinfo.type = SINFO_T_CAPINFO;
1284 sec.capinfo.vaddr = dyn->d_un.d_ptr;
1288 sec.capchain.type = SINFO_T_CAPCHAIN;
1289 sec.capchain.vaddr = dyn->d_un.d_ptr;
1293 sec.ldynsym.type = SINFO_T_LDYNSYM;
1294 sec.ldynsym.vaddr = dyn->d_un.d_ptr;
1298 sec.ldynsym.size = dyn->d_un.d_val;
1302 sec.symsort.type = SINFO_T_SYMSORT;
1303 sec.symsort.vaddr = dyn->d_un.d_ptr;
1307 sec.symsort.size = dyn->d_un.d_val;
1311 sec.tlssort.type = SINFO_T_TLSSORT;
1312 sec.tlssort.vaddr = dyn->d_un.d_ptr;
1316 sec.tlssort.size = dyn->d_un.d_val;
1320 sec.move.type = SINFO_T_MOVE;
1321 sec.move.vaddr = dyn->d_un.d_ptr;
1325 sec.move.size = dyn->d_un.d_val;
1329 sec.syminfo.type = SINFO_T_SYMINFO;
1330 sec.syminfo.vaddr = dyn->d_un.d_ptr;
1334 sec.syminfo.size = dyn->d_un.d_val;
1338 sec.versym.type = SINFO_T_VERSYM;
1339 sec.versym.vaddr = dyn->d_un.d_ptr;
1343 sec.verdef.type = SINFO_T_VERDEF;
1344 sec.verdef.vaddr = dyn->d_un.d_ptr;
1348 sec.verdef.vercnt = dyn->d_un.d_val;
1349 sec.verdef.size = sizeof (Verdef) *
1354 sec.verneed.type = SINFO_T_VERNEED;
1355 sec.verneed.vaddr = dyn->d_un.d_ptr;
1359 sec.verneed.vercnt = dyn->d_un.d_val;
1360 sec.verneed.size = sizeof (Verneed) *
1378 if (sec.dynstr.size == 0)
1379 sec.dynstr.type = SINFO_T_NULL;
1380 if (sec.dynstr.type != SINFO_T_DYNSTR) {
1381 sinfo_free(&sec.dyn, 1); /* Data already fetched */
1382 sec.dynsym.type = SINFO_T_NULL;
1383 sec.dynsym.type = SINFO_T_NULL;
1384 sec.verdef.type = SINFO_T_NULL;
1385 sec.verneed.type = SINFO_T_NULL;
1397 if (sec.hash.type == SINFO_T_HASH) {
1402 if (hash_size(&fstate, &sec.hash,
1404 sec.hash.type = SINFO_T_NULL;
1407 sec.hash.size = total * sizeof (Word);
1408 sec.dynsym.size = nchain * sizeof (Sym);
1409 sec.versym.size = nchain * sizeof (Versym);
1417 if (sec.ldynsym.size > sec.dynsym.size)
1418 sec.ldynsym.size -= sec.dynsym.size;
1426 if (sec.hash.type != SINFO_T_HASH) {
1427 sec.dynsym.type = SINFO_T_NULL;
1428 sec.ldynsym.type = SINFO_T_NULL;
1429 sec.versym.type = SINFO_T_NULL;
1437 if ((sec.verdef.type == SINFO_T_VERDEF) &&
1438 (verdefneed_size(&fstate, &sec.verdef) == 0))
1439 sec.verdef.type = SINFO_T_NULL;
1440 if ((sec.verneed.type == SINFO_T_VERNEED) &&
1441 (verdefneed_size(&fstate, &sec.verneed) == 0))
1442 sec.verneed.type = SINFO_T_NULL;
1451 if (sec.dynsym.type != SINFO_T_DYNSYM) {
1452 sec.ldynsym.type = SINFO_T_NULL;
1453 sec.hash.type = SINFO_T_NULL;
1454 sec.syminfo.type = SINFO_T_NULL;
1455 sec.versym.type = SINFO_T_NULL;
1456 sec.move.type = SINFO_T_NULL;
1457 sec.rel.type = SINFO_T_NULL;
1458 sec.rela.type = SINFO_T_NULL;
1462 if (sec.ldynsym.type != SINFO_T_DYNSYM) {
1463 sec.symsort.type = SINFO_T_NULL;
1464 sec.tlssort.type = SINFO_T_NULL;
1491 * to build up sec and seclist, so on success, we have nothing
1495 *shnum = num_sinfo + num_list_sinfo + 1; /* Extra for 1st NULL sec. */