Lines Matching +defs:buffer +defs:file +defs:name

197 // Returns slices of MB by parsing MB as an archive file.
198 // Each slice consists of a member file in the archive.
201 std::unique_ptr<Archive> file =
207 bool addToTar = file->isThin() && ctx.tar;
208 for (const Archive::Child &c : file->children(err)) {
212 ": could not get the buffer for a child of the archive");
223 std::vector<std::unique_ptr<MemoryBuffer>> mbs = file->takeThinBuffers();
246 // Opens a file and create a file object. Path has to be resolved already.
250 std::optional<MemoryBufferRef> buffer = readFile(ctx, path);
251 if (!buffer)
253 MemoryBufferRef mbref = *buffer;
281 // archive rather than just the index file, with the benefit that the
316 // DT_SONAME and falls back to filename. If a file was specified by -lfoo,
334 ErrAlways(ctx) << path << ": unknown file type";
339 void LinkerDriver::addLibrary(StringRef name) {
340 if (std::optional<std::string> path = searchLibrary(ctx, name))
343 ctx.e.error("unable to find library -l" + name, ErrorTag::LibNotFound,
344 {name});
689 // symbols after the name resolution.
853 StringRef name;
855 std::tie(name, addr) = StringRef(arg->getValue()).split('=');
856 ret[name] = parseSectionAddress(ctx, addr, args, *arg);
872 if (s == "name")
933 // Build a map from symbol name to section
935 for (ELFFileBase *file : ctx.objectFiles)
936 for (Symbol *sym : file->getSymbols())
939 auto findSection = [&](StringRef name) -> InputSectionBase * {
940 Symbol *sym = map.lookup(name);
943 Warn(ctx) << mb.getBufferIdentifier() << ": no such symbol: " << name;
1024 for (auto file : ctx.objectFiles) {
1025 auto *obj = cast<ObjFile<ELFT>>(file);
1054 auto processVtableAndTypeInfoSymbols = [&](StringRef name) {
1055 if (name.consume_front("_ZTI"))
1056 typeInfoSymbols.insert(name);
1057 else if (name.consume_front("_ZTV"))
1058 vtableSymbols.insert(name);
1066 StringRef name = check(s.getName(f->getStringTable()));
1067 processVtableAndTypeInfoSymbols(name);
1076 StringRef name = check(s.getName(f->getStringTable()));
1077 processVtableAndTypeInfoSymbols(name);
1168 // Parse the symbol ordering file and warn for any duplicate entries.
1214 // Process a remap pattern 'from-glob=to-file'.
1219 ErrAlways(ctx) << location << ": parse error, not 'from-glob=to-file'";
1532 std::optional<MemoryBufferRef> buffer = readFile(ctx, filename);
1533 if (!buffer)
1535 // Parse 'from-glob=to-file' lines, ignoring #-led comments.
1536 for (auto [lineno, line] : llvm::enumerate(args::getLines(*buffer)))
1755 ErrAlways(ctx) << "--symbol-ordering-file and --call-graph-order-file "
1757 if (auto buffer = readFile(ctx, arg->getValue()))
1758 ctx.arg.symbolOrderingFile = getSymbolOrderingFile(ctx, *buffer);
1767 // If --retain-symbol-file is used, we'll keep only the symbols listed in
1768 // the file and discard all others.
1772 if (std::optional<MemoryBufferRef> buffer = readFile(ctx, arg->getValue()))
1773 for (StringRef s : args::getLines(*buffer))
1804 if (std::optional<MemoryBufferRef> buffer = readFile(ctx, arg->getValue()))
1805 readDynamicList(ctx, *buffer);
1809 if (std::optional<MemoryBufferRef> buffer = readFile(ctx, *path))
1810 readVersionScript(ctx, *buffer);
1880 // Set default entry point and output file if not specified by command line or
1889 // Fail early if the output file or map file is not writable. If a user has a
1895 ErrAlways(ctx) << "cannot open output file " << ctx.arg.outputFile << ": "
1898 ErrAlways(ctx) << "cannot open map file " << ctx.arg.mapFile << ": "
1901 ErrAlways(ctx) << "cannot open --why-extract= file " << ctx.arg.whyExtract
2064 << "target emulation unknown: -m or at least one .o file required";
2143 // Handles the --exclude-libs option. If a static library file is specified
2146 // A special library name "ALL" means all archive files.
2153 auto visit = [&](InputFile *file) {
2154 if (file->archiveName.empty() ||
2155 !(all || libs.count(path::filename(file->archiveName))))
2157 ArrayRef<Symbol *> symbols = file->getSymbols();
2158 if (isa<ELFFileBase>(file))
2159 symbols = cast<ELFFileBase>(file)->getGlobalSymbols();
2161 if (!sym->isUndefined() && sym->file == file) {
2168 for (ELFFileBase *file : ctx.objectFiles)
2169 visit(file);
2171 for (BitcodeFile *file : ctx.bitcodeFiles)
2172 visit(file);
2185 ctx.whyExtractRecords.emplace_back(option, sym->file, *sym);
2209 static void handleLibcall(Ctx &ctx, StringRef name) {
2210 Symbol *sym = ctx.symtab->find(name);
2211 if (sym && sym->isLazy() && isa<BitcodeFile>(sym->file)) {
2213 ctx.whyExtractRecords.emplace_back("<libcall>", sym->file, *sym);
2234 for (ELFFileBase *file : ctx.objectFiles)
2235 if (file->archiveName.size())
2236 ++extracted[CachedHashStringRef(file->archiveName)];
2237 for (BitcodeFile *file : ctx.bitcodeFiles)
2238 if (file->archiveName.size())
2239 ++extracted[CachedHashStringRef(file->archiveName)];
2255 ErrAlways(ctx) << "cannot open --why-extract= file " << ctx.arg.whyExtract
2286 // Handle --dependency-file=<path>. If that option is given, lld creates a
2287 // file at a given path with the following contents:
2289 // <output-file>: <input-file> ...
2291 // <input-file>:
2293 // where <output-file> is a pathname of an output file and <input-file>
2295 // file in the above format and interpret it as a dependency info. We write
2296 // phony targets for every <input-file> to avoid an error when that file is
2307 // part of your program. By using --dependency-file option, you can make
2362 for (ELFFileBase *file : ctx.objectFiles) {
2363 if (!file->hasCommonSyms)
2365 for (Symbol *sym : file->getGlobalSymbols()) {
2371 bss->file = s->file;
2373 Defined(ctx, s->file, StringRef(), s->binding, s->stOther, s->type,
2397 StringRef name = arg->getValue();
2398 auto *d = dyn_cast_or_null<Defined>(ctx.symtab->find(name));
2400 Warn(ctx) << "could not find symbol " << name << " to keep unique";
2419 // Visit the address-significance table in each object file and mark each
2440 // If an object file does not have an address-significance table,
2456 auto readEntry = [](InputFile *file, const auto &rels) -> Symbol * {
2458 return &file->getRelocTargetSym(rel);
2462 sym = readEntry(s->file, rels.crels);
2464 sym = readEntry(s->file, rels.rels);
2466 sym = readEntry(s->file, rels.relas);
2472 if (part.name == partName) {
2482 ErrAlways(ctx) << s->file
2485 ErrAlways(ctx) << s->file
2488 ErrAlways(ctx) << s->file
2492 ErrAlways(ctx) << s->file << ": partitions cannot be used on this target";
2502 newPart.name = partName;
2508 // (except symbol/section names used by infrequent passes). Mark input file
2519 for (BitcodeFile *file : ctx.bitcodeFiles)
2520 bufs.insert(file->mb.getBufferStart());
2521 for (BitcodeFile *file : ctx.lazyBitcodeFiles)
2522 bufs.insert(file->mb.getBufferStart());
2530 // not in native object file format but in the LLVM bitcode format.
2540 for (BitcodeFile *file : ctx.bitcodeFiles)
2541 lto->add(*file);
2547 for (auto &file : ltoObjectFiles) {
2548 auto *obj = cast<ObjFile<ELFT>>(file.get());
2591 StringRef name = arg->getValue();
2592 if (!seen.insert(name).second)
2595 Symbol *sym = ctx.symtab->find(name);
2600 ctx.symtab->addUnusedUndefined(ss.save("__wrap_" + name), sym->binding);
2604 StringRef realName = ctx.saver.save("__real_" + name);
2606 ctx.symtab->addUnusedUndefined(name, sym->binding);
2620 // If a symbol is referenced in any object file, bitcode file or shared
2623 // to not eliminate the redirection target. If the object file defining the
2670 ? ctx.arg.versionDefinitions[sym2->versionId].name == suffix1 + 1
2710 parallelForEach(ctx.objectFiles, [&](ELFFileBase *file) {
2711 for (Symbol *&sym : file->getMutableGlobalSymbols())
2722 // source file must be compiled with -fcf-protection. Object files compiled
2771 << ": -z bti-report: file does not have "
2777 << ": -z gcs-report: file does not have "
2782 << ": -z cet-report: file does not have "
2788 << ": -z cet-report: file does not have "
2795 << ": -z force-bti: file does not have "
2801 << ": -z force-ibt: file does not have "
2808 << ": -z pac-plt: file does not have "
2821 << ": -z pauth-report: file does not have AArch64 "
2846 static void initSectionsAndLocalSyms(ELFFileBase *file, bool ignoreComdats) {
2847 switch (file->ekind) {
2849 cast<ObjFile<ELF32LE>>(file)->initSectionsAndLocalSyms(ignoreComdats);
2852 cast<ObjFile<ELF32BE>>(file)->initSectionsAndLocalSyms(ignoreComdats);
2855 cast<ObjFile<ELF64LE>>(file)->initSectionsAndLocalSyms(ignoreComdats);
2858 cast<ObjFile<ELF64BE>>(file)->initSectionsAndLocalSyms(ignoreComdats);
2865 static void postParseObjectFile(ELFFileBase *file) {
2866 switch (file->ekind) {
2868 cast<ObjFile<ELF32LE>>(file)->postParse();
2871 cast<ObjFile<ELF32BE>>(file)->postParse();
2874 cast<ObjFile<ELF64LE>>(file)->postParse();
2877 cast<ObjFile<ELF64BE>>(file)->postParse();
2897 for (StringRef name : ctx.arg.undefined)
2898 ctx.symtab->addUnusedUndefined(name)->referenced = true;
2909 // If an entry symbol is in a static archive, pull out that file now.
2923 for (StringRef name : ctx.arg.undefined)
2924 if (Defined *sym = dyn_cast_or_null<Defined>(ctx.symtab->find(name)))
2935 // bitcode file's symbol table. If any of those library functions are defined
2936 // in a bitcode file in an archive member, we need to arrange to use LTO to
2949 // object file to the link.
2961 parallelForEach(ctx.objectFiles, [](ELFFileBase *file) {
2962 initSectionsAndLocalSyms(file, /*ignoreComdats=*/false);
2966 [](BitcodeFile *file) { file->postParse(); });
2969 Undefined(sym.file, sym.getName(), sym.binding, sym.stOther, sym.type,
2976 reportDuplicate(ctx, *d.sym, d.file, d.section, d.value);
2979 // Return if there were name resolution errors.
3008 // name "foo@ver1") rather do harm, so we don't call this if -r is given.
3018 // For --thinlto-index-only, index file creation is performed in
3022 // compilation, the intermediate object file are the expected output.
3053 // more file will be added.
3055 parallelForEach(newObjectFiles, [](ELFFileBase *file) {
3056 initSectionsAndLocalSyms(file, /*ignoreComdats=*/true);
3060 reportDuplicate(ctx, *d.sym, d.file, d.section, d.value);
3072 Err(ctx) << "input file '" << newFile->getName() << "' added after LTO";
3137 // a .d file to record build dependencies.
3237 if (std::optional<MemoryBufferRef> buffer =
3239 readCallGraph(ctx, *buffer);
3244 // Write the result to the file.