Lines Matching full:fileinfo
62 static int ld_generic_file_close (struct usedfiles *fileinfo,
64 static int ld_generic_file_process (int fd, struct usedfiles *fileinfo,
98 static int file_process2 (struct usedfiles *fileinfo);
127 print_file_name (FILE *s, struct usedfiles *fileinfo, int first_level,
132 if (fileinfo->archive_file != NULL)
134 npar = print_file_name (s, fileinfo->archive_file, 0, 0) + 1;
136 fputs_unlocked (fileinfo->rfname, s);
143 fputs_unlocked (fileinfo->rfname, s);
164 struct usedfiles *file = scninfo->fileinfo;
335 open_along_path2 (struct usedfiles *fileinfo, struct pathelement *path)
337 const char *fname = fileinfo->fname;
355 if (fileinfo->file_type == archive_file_type)
386 assert (fileinfo->file_type == dso_file_type
387 || fileinfo->file_type == dso_needed_file_type);
402 fileinfo->fd = fd;
406 if (unlikely (check_for_duplicate (fileinfo) != 0))
410 fileinfo->rfname = obstack_strdup (&ld_state.smem, rfname);
413 printf (fileinfo->file_type == archive_file_type
455 open_along_path (struct usedfiles *fileinfo)
457 const char *fname = fileinfo->fname;
460 if (fileinfo->file_type == relocatable_file_type)
463 fileinfo->fd = open (fname, O_RDONLY);
465 if (likely (fileinfo->fd != -1))
469 print_file_name (stdout, fileinfo, 1, 1);
471 return check_for_duplicate (fileinfo);
481 err = open_along_path2 (fileinfo, ld_state.ld_library_path1);
485 err = open_along_path2 (fileinfo,
486 fileinfo->file_type == archive_file_type
492 err = open_along_path2 (fileinfo, ld_state.ld_library_path2);
497 if (fileinfo->file_type == dso_file_type)
498 err = open_along_path2 (fileinfo, ld_state.runpath_link);
502 err = open_along_path2 (fileinfo, ld_state.default_paths);
508 && (err != EAGAIN || fileinfo->file_type == relocatable_file_type))
509 error (0, err, gettext ("cannot open %s"), fileinfo->fname);
517 struct usedfiles *fileinfo, struct symbol *oldp)
524 size_t newgrpid = fileinfo->scninfo[shndx].grpid;
529 assert (SCNINFO_SHDR (fileinfo->scninfo[newgrpid].shdr).sh_type
534 if (! fileinfo->scninfo[newgrpid].comdat_group
538 if (strcmp (fileinfo->scninfo[newgrpid].symbols->name,
548 check_type_and_size (const XElf_Sym *sym, struct usedfiles *fileinfo,
571 fileinfo->rfname);
579 (uint64_t) sym->st_size, fileinfo->rfname);
585 struct usedfiles *fileinfo, struct symbol *oldp)
589 bool new_in_dso = FILEINFO_EHDR (fileinfo->ehdr).e_type == ET_DYN;
603 check_type_and_size (sym, fileinfo, oldp);
626 && matching_group_comdat_scn (sym, shndx, fileinfo, oldp))
639 && ! old_in_dso && fileinfo->file_type == relocatable_file_type)
649 if (elf_getshdrnum (fileinfo->elf, &shnum) < 0)
656 scnname = elf_strptr (fileinfo->elf,
657 fileinfo->shstrndx,
658 SCNINFO_SHDR (fileinfo->scninfo[shndx].shdr).sh_name);
665 print_file_name (stderr, fileinfo, 1, 0);
696 else if (old_in_dso && fileinfo->file_type == relocatable_file_type
728 if (old_in_dso && fileinfo->file_type == relocatable_file_type)
747 oldp->file = fileinfo;
751 if (likely (fileinfo->file_type == relocatable_file_type))
761 mark_section_used (&fileinfo->scninfo[shndx], shndx, &ignore);
794 find_section_group (struct usedfiles *fileinfo, Elf32_Word shndx,
799 for (runp = fileinfo->groups; runp != NULL; runp = runp->next)
810 fileinfo->fname, elf_errmsg (-1));
832 fileinfo->fname,
833 elf_strptr (fileinfo->elf, fileinfo->shstrndx,
834 SCNINFO_SHDR (fileinfo->scninfo[shndx].shdr).sh_name));
842 mark_section_group (struct usedfiles *fileinfo, Elf32_Word shndx,
850 struct scninfo *grpscn = find_section_group (fileinfo, shndx, &data);
872 XElf_Shdr *shdr = &SCNINFO_SHDR (fileinfo->scninfo[idx].shdr);
874 if (fileinfo->scninfo[idx].grpid != grpscn->grpid)
877 fileinfo->fname, (int) idx,
878 elf_strptr (fileinfo->elf, fileinfo->shstrndx, shdr->sh_name));
883 elf_strptr (fileinfo->elf, fileinfo->shstrndx,
888 elf_strptr (fileinfo->elf,
889 fileinfo->shstrndx,
890 SCNINFO_SHDR (fileinfo->scninfo[shdr->sh_info].shdr).sh_name)))))
894 mark_section_used (&fileinfo->scninfo[idx], idx, &ignore);
934 mark_section_used (&scninfo->fileinfo->scninfo[shdr->sh_link],
942 mark_section_used (&scninfo->fileinfo->scninfo[shdr->sh_info],
948 mark_section_group (scninfo->fileinfo, shndx, grpscnp);
957 add_section (struct usedfiles *fileinfo, struct scninfo *scninfo)
979 && strcmp (elf_strptr (fileinfo->elf,
980 fileinfo->shstrndx,
982 && (fileinfo->status != in_archive || !ld_state.gc_sections))
989 grpscn = find_section_group (fileinfo, elf_ndxscn (scninfo->scn),
994 search.name = elf_strptr (fileinfo->elf, fileinfo->shstrndx, shdr->sh_name);
1034 = find_section_group (runp->fileinfo,
1088 add_relocatable_file (struct usedfiles *fileinfo, GElf_Word secttype)
1107 assert (fileinfo->elf != NULL);
1110 if (unlikely (elf_getshdrnum (fileinfo->elf, &scncnt) < 0))
1115 fileinfo->scninfo = (struct scninfo *)
1126 fileinfo->scninfo[cnt].scn = elf_getscn (fileinfo->elf, cnt);
1131 if (fileinfo->scninfo[cnt].shdr == NULL)
1133 if (fileinfo->scninfo[cnt].shdr.sh_type == SHT_NULL)
1137 shdr = xelf_getshdr (fileinfo->scninfo[cnt].scn,
1138 fileinfo->scninfo[cnt].shdr);
1140 xelf_getshdr_copy (fileinfo->scninfo[cnt].scn, shdr,
1141 fileinfo->scninfo[cnt].shdr);
1147 fileinfo->rfname, __FILE__, __LINE__);
1152 shdr = &SCNINFO_SHDR (fileinfo->scninfo[cnt].shdr);
1154 Elf_Data *data = elf_getdata (fileinfo->scninfo[cnt].scn, NULL);
1162 fileinfo->scninfo[cnt].fileinfo = fileinfo;
1169 assert (fileinfo->symtabdata == NULL);
1170 fileinfo->symtabdata = data;
1171 fileinfo->nsymtab = shdr->sh_size / shdr->sh_entsize;
1172 fileinfo->nlocalsymbols = shdr->sh_info;
1173 fileinfo->symstridx = shdr->sh_link;
1177 assert (fileinfo->dynsymtabdata == NULL);
1178 fileinfo->dynsymtabdata = data;
1179 fileinfo->ndynsymtab = shdr->sh_size / shdr->sh_entsize;
1180 fileinfo->dynsymstridx = shdr->sh_link;
1197 fileinfo->xndxdata = xndxdata = data;
1202 fileinfo->versymdata = versymdata = data;
1209 fileinfo->verdefdata = verdefdata = data;
1213 fileinfo->nverdef = nversions = shdr->sh_info;
1216 fileinfo->verdefused = (XElf_Versym *)
1219 fileinfo->verdefent = (struct Ebl_Strent **)
1226 fileinfo->verneeddata = verneeddata = data;
1230 assert (fileinfo->dynscn == NULL);
1231 fileinfo->dynscn = fileinfo->scninfo[cnt].scn;
1239 if (FILEINFO_EHDR (fileinfo->ehdr).e_type != ET_REL)
1242 fileinfo->fname);
1244 fileinfo->scninfo[cnt].next = fileinfo->groups;
1245 fileinfo->scninfo[cnt].grpid = cnt;
1246 fileinfo->groups = &fileinfo->scninfo[cnt];
1250 fileinfo->scninfo[cnt].symbols = (struct symbol *)
1253 symscn = elf_getscn (fileinfo->elf, shdr->sh_link);
1266 struct symbol *symbol = fileinfo->scninfo[cnt].symbols;
1272 xelf_getshdr (elf_getscn (fileinfo->elf, sym->st_shndx),
1275 symbol->name = elf_strptr (fileinfo->elf,
1276 FILEINFO_EHDR (fileinfo->ehdr).e_shstrndx,
1283 symbol->name = elf_strptr (fileinfo->elf,
1288 symbol->file = fileinfo;
1291 if (fileinfo->scninfo[cnt].symbols->name == NULL)
1294 fileinfo->fname,
1295 elf_ndxscn (fileinfo->scninfo[cnt].scn),
1296 elf_strptr (fileinfo->elf, fileinfo->shstrndx,
1306 fileinfo->fname, elf_ndxscn (fileinfo->scninfo[cnt].scn),
1307 elf_strptr (fileinfo->elf, fileinfo->shstrndx,
1313 fileinfo->scninfo[cnt].comdat_group = true;
1320 fileinfo->fname,
1321 inner, elf_ndxscn (fileinfo->scninfo[cnt].scn),
1322 elf_strptr (fileinfo->elf, fileinfo->shstrndx,
1326 fileinfo->scninfo[grpdata[inner]].grpid = cnt;
1332 assert (fileinfo->scninfo[cnt].used == false);
1341 fileinfo->fname,
1342 elf_strptr (fileinfo->elf, fileinfo->shstrndx,
1349 else if (likely (fileinfo->file_type == relocatable_file_type)
1363 && strcmp (elf_strptr (fileinfo->elf, fileinfo->shstrndx,
1368 add_section (fileinfo, &fileinfo->scninfo[cnt]);
1374 if (fileinfo->file_type == relocatable_file_type
1386 fileinfo->has_merge_sections = has_merge_sections;
1389 fileinfo->symref = (struct symbol **)
1404 fileinfo->rfname, __FILE__, __LINE__);
1413 fileinfo->rfname, __FILE__, __LINE__);
1419 && ((SCNINFO_SHDR (fileinfo->scninfo[shndx].shdr).sh_flags
1432 newp->file = fileinfo;
1434 fileinfo->symref[cnt] = newp;
1436 if (fileinfo->scninfo[shndx].symbols == NULL)
1437 fileinfo->scninfo[shndx].symbols = newp->next_in_scn
1442 = fileinfo->scninfo[shndx].symbols->next_in_scn;
1443 fileinfo->scninfo[shndx].symbols
1444 = fileinfo->scninfo[shndx].symbols->next_in_scn = newp;
1455 fileinfo->symref = (struct symbol **)
1472 fileinfo->rfname, __FILE__, __LINE__);
1481 fileinfo->rfname, __FILE__, __LINE__);
1491 && fileinfo->scninfo[shndx].unused_comdat)
1512 search.name = elf_strptr (fileinfo->elf, symstridx, sym->st_name);
1526 && fileinfo->file_type != relocatable_file_type)
1544 newp->file = fileinfo;
1582 fileinfo->symref[cnt] = newp;
1594 else if (unlikely (check_definition (sym, shndx, cnt, fileinfo, oldp)
1602 newp = fileinfo->symref[cnt] = oldp;
1612 assert (elf_getshdrnum (fileinfo->elf, &shnum) == 0);
1617 mark_section_used (&fileinfo->scninfo[shndx], shndx, &ignore);
1621 if (SCNINFO_SHDR (fileinfo->scninfo[shndx].shdr).sh_flags
1624 if (fileinfo->scninfo[shndx].symbols == NULL)
1625 fileinfo->scninfo[shndx].symbols = newp->next_in_scn
1630 = fileinfo->scninfo[shndx].symbols->next_in_scn;
1631 fileinfo->scninfo[shndx].symbols
1632 = fileinfo->scninfo[shndx].symbols->next_in_scn = newp;
1639 if (likely (fileinfo->file_type == relocatable_file_type))
1642 ld_state.relfiles = fileinfo->next = fileinfo;
1645 fileinfo->next = ld_state.relfiles->next;
1646 ld_state.relfiles = ld_state.relfiles->next = fileinfo;
1650 ld_state.nsymtab += fileinfo->nsymtab;
1651 ld_state.nlocalsymbols += fileinfo->nlocalsymbols;
1653 else if (likely (fileinfo->file_type == dso_file_type))
1655 CSNGL_LIST_ADD_REAR (ld_state.dsofiles, fileinfo);
1658 if (fileinfo->lazyload)
1713 open_elf (struct usedfiles *fileinfo, Elf *elf)
1727 fileinfo->status = closed;
1730 if (fileinfo->fd != -1)
1732 ldin = fdopen (fileinfo->fd, "r");
1744 fileinfo->rfname, __FILE__, __LINE__);
1758 fileinfo->rfname);
1765 ldin_fname = fileinfo->rfname;
1769 if (fileinfo->fd != -1 && !fileinfo->fd_passed)
1772 close (fileinfo->fd);
1773 fileinfo->fd = -1;
1783 fileinfo->elf = NULL;
1808 fileinfo->elf = elf;
1811 fileinfo->status = opened;
1818 add_whole_archive (struct usedfiles *fileinfo)
1824 while ((arelf = elf_begin (fileinfo->fd, cmd, fileinfo->elf)) != NULL)
1838 newp->archive_file = fileinfo;
1864 extract_from_archive (struct usedfiles *fileinfo)
1869 if (fileinfo->archive_seq == 0)
1872 fileinfo->archive_seq = ++archive_seq;
1885 syms = elf_getarsym (fileinfo->elf, &nsyms);
1890 fileinfo->rfname, elf_errmsg (-1));
1893 fileinfo->status = closed;
1921 if (unlikely (elf_rand (fileinfo->elf, syms[cnt].as_off)
1927 arelf = elf_begin (fileinfo->fd, ELF_C_READ_MMAP_PRIVATE,
1928 fileinfo->elf);
1939 newp->archive_file = fileinfo;
1963 assert (fileinfo->archive_seq != 0);
1964 ld_state.last_archive_used = fileinfo->archive_seq;
1974 file_process2 (struct usedfiles *fileinfo)
1978 if (likely (elf_kind (fileinfo->elf) == ELF_K_ELF))
1982 if (likely (fileinfo->ehdr == NULL))
1984 if (likely (FILEINFO_EHDR (fileinfo->ehdr).e_type == ET_NONE))
1989 ehdr = xelf_getehdr (fileinfo->elf, fileinfo->ehdr);
1991 xelf_getehdr_copy (fileinfo->elf, ehdr, fileinfo->ehdr);
1996 fileinfo->rfname, __FILE__, __LINE__);
1997 fileinfo->status = closed;
2001 if (FILEINFO_EHDR (fileinfo->ehdr).e_type != ET_REL
2002 && unlikely (FILEINFO_EHDR (fileinfo->ehdr).e_type != ET_DYN))
2008 print_file_name (stderr, fileinfo, 1, 0);
2012 FILEINFO_EHDR (fileinfo->ehdr).e_type,
2014 fileinfo->status = closed;
2019 if (FILEINFO_EHDR (fileinfo->ehdr).e_machine
2024 fileinfo->rfname,
2026 fileinfo->status = closed;
2031 if (unlikely (elf_getshdrstrndx (fileinfo->elf, &fileinfo->shstrndx)
2036 fileinfo->rfname, elf_errmsg (-1));
2037 fileinfo->status = closed;
2043 if (FILEINFO_EHDR (fileinfo->ehdr).e_type == ET_REL)
2047 res = add_relocatable_file (fileinfo, SHT_SYMTAB);
2051 bool has_l_name = fileinfo->file_type == archive_file_type;
2053 assert (FILEINFO_EHDR (fileinfo->ehdr).e_type == ET_DYN);
2057 if (fileinfo->file_type != dso_needed_file_type)
2058 fileinfo->file_type = dso_file_type;
2065 fileinfo->fname);
2071 res = add_relocatable_file (fileinfo, SHT_DYNSYM);
2074 assert (fileinfo->dynscn != NULL);
2079 xelf_getshdr (fileinfo->dynscn, dynshdr);
2081 Elf_Data *dyndata = elf_getdata (fileinfo->dynscn, NULL);
2097 newp = ld_new_inputfile (elf_strptr (fileinfo->elf,
2111 fileinfo->soname = elf_strptr (fileinfo->elf,
2127 size_t len = strlen (fileinfo->fname) + 7;
2131 strcpy (stpcpy (stpcpy (newp, "lib"), fileinfo->fname), ".so");
2133 fileinfo->soname = newp;
2137 else if (likely (elf_kind (fileinfo->elf) == ELF_K_AR))
2142 res = add_whole_archive (fileinfo);
2148 error (0, 0, gettext ("input file '%s' ignored"), fileinfo->fname);
2156 ld_state.group_start_archive = fileinfo;
2159 ld_state.archives = fileinfo;
2162 ld_state.tailarchives->next = fileinfo;
2163 ld_state.tailarchives = fileinfo;
2167 res = extract_from_archive (fileinfo);
2184 ld_generic_file_process (int fd, struct usedfiles *fileinfo,
2190 *nextp = fileinfo->next;
2193 if (unlikely (fileinfo->group_start))
2196 fileinfo->group_start = false;
2200 if (likely (fileinfo->status == not_opened))
2207 int err = open_along_path (fileinfo);
2216 fileinfo->fd = fd;
2219 fileinfo->fd_passed = fd_passed;
2227 res = open_elf (fileinfo, elf_begin (fileinfo->fd,
2228 is_dso_p (fileinfo->fd)
2236 if (likely (fileinfo->status != closed))
2237 res = file_process2 (fileinfo);
2240 if (unlikely (fileinfo->group_backref != NULL))
2244 if (ld_state.last_archive_used > fileinfo->group_backref->archive_seq)
2246 *nextp = fileinfo->group_backref;
2266 while (runp != fileinfo->next);
2272 *nextp = fileinfo->next = NULL;
2275 else if (unlikely (fileinfo->group_end))
2294 if (ld_state.tailarchives != fileinfo)
2304 fileinfo->group_end = false;
2386 ld_generic_file_close (struct usedfiles *fileinfo, struct ld_state *statep)
2389 elf_end (fileinfo->elf);
2393 if (!fileinfo->fd_passed && fileinfo->fd != -1)
2394 close (fileinfo->fd);
2397 if (fileinfo->fname != fileinfo->rfname)
2398 free ((char *) fileinfo->rfname);
2857 const char *brfname = basename (runp->fileinfo->rfname);
3201 here_groupidx = runp->fileinfo->scninfo[runp->grpid].outscnndx;
3230 elf_strptr (runp->fileinfo->elf,
3231 runp->fileinfo->shstrndx,
3236 = runp->fileinfo->scninfo[runp->grpid].symbols;
3263 if (runp->fileinfo->scninfo[runp->grpid].outscnndx == 0)
3264 runp->fileinfo->scninfo[runp->grpid].outscnndx = here_groupidx;
3266 assert (runp->fileinfo->scninfo[runp->grpid].outscnndx
6875 rellist->scninfo->fileinfo->scninfo[SCNINFO_SHDR (rellist->scninfo->shdr).sh_info].outscnndx;