Lines Matching +full:embedded +full:- +full:trace +full:- +full:extension

1 //===- Driver.cpp ---------------------------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
29 #include "llvm/Config/llvm-config.h"
51 #include "llvm/ToolDrivers/llvm-lib/LibDriver.h"
67 // This driver-specific context will be freed later by unsafeLldMain(). in link()
70 ctx->e.initialize(stdoutOS, stderrOS, exitEarly, disableOutput); in link()
71 ctx->e.logName = args::getFilenameWithoutExe(args[0]); in link()
72 ctx->e.errorLimitExceededMsg = "too many errors emitted, stopping now" in link()
75 ctx->driver.linkerMain(args); in link()
87 StringRef s = arg->getValue(); in getOldNewOptions()
90 error(arg->getSpelling() + " expects 'old;new' format, but got " + s); in getOldNewOptions()
102 // Drop directory components and replace extension with
136 // asynchronously. But 32-bit has issues with potentially launching tons in createFutureForFile()
173 ctx.driver.tar->append(relativeToRoot(mbref.getBufferIdentifier()), in takeBuffer()
180 StringRef filename = mb->getBufferIdentifier(); in addBuffer()
185 // File type is detected by contents, not by file extension. in addBuffer()
199 addArchiveBuffer(m, "<whole-archive>", filename, memberIndex++); in addBuffer()
240 auto [mb, ec] = future->get(); in enqueuePath()
283 imp->parentName = parentName; in addArchiveBuffer()
303 obj->parentName = parentName; in addArchiveBuffer()
318 if (!c.getParent()->isThin()) { in enqueueArchiveMember()
339 auto mbOrErr = future->get(); in enqueueArchiveMember()
343 mbOrErr.first->getBufferIdentifier()); in enqueueArchiveMember()
360 StringRef s = file->getDirectives(); in parseDirectives()
394 // Handle /exclude-symbols: in bulk. in parseDirectives()
402 // https://docs.microsoft.com/en-us/cpp/preprocessor/comment-c-cpp?view=msvc-160 in parseDirectives()
404 switch (arg->getOption().getID()) { in parseDirectives()
406 parseAligncomm(arg->getValue()); in parseDirectives()
409 parseAlternateName(arg->getValue()); in parseDirectives()
412 if (std::optional<StringRef> path = findLibIfNew(arg->getValue())) in parseDirectives()
416 if (!arg->getValue()[0]) in parseDirectives()
418 ctx.config.entry = addUndefined(mangle(arg->getValue())); in parseDirectives()
421 checkFailIfMismatch(arg->getValue(), file); in parseDirectives()
424 addUndefined(arg->getValue()); in parseDirectives()
427 ctx.config.manifestDependencies.insert(arg->getValue()); in parseDirectives()
430 parseMerge(arg->getValue()); in parseDirectives()
433 ctx.config.noDefaultLibs.insert(findLib(arg->getValue()).lower()); in parseDirectives()
439 parseSection(arg->getValue()); in parseDirectives()
442 parseNumbers(arg->getValue(), &ctx.config.stackReserve, in parseDirectives()
447 parseSubsystem(arg->getValue(), &ctx.config.subsystem, in parseDirectives()
457 // `#pragma comment(linker, "/flag")`-generated sections. in parseDirectives()
465 error(arg->getSpelling() + " is not allowed in .drectve (" + in parseDirectives()
474 auto getFilename = [this](StringRef filename) -> StringRef { in findFile()
476 if (auto statOrErr = ctx.config.vfs->status(filename)) in findFile()
477 return saver().save(statOrErr->getName()); in findFile()
523 // MinGW specific. If an embedded directive specified to link to
537 // Add ".lib" to Filename if that has no file extension. in findLib()
577 VCToolsDir = A->getValue(); in detectWinSysRoot()
579 VCToolsVersion = A->getValue(); in detectWinSysRoot()
581 WinSysRoot = A->getValue(); in detectWinSysRoot()
596 diaPath = A->getValue(); in detectWinSysRoot()
597 if (A->getOption().getID() == OPT_winsysroot) in detectWinSysRoot()
607 WinSdkDir = A->getValue(); in detectWinSysRoot()
609 WinSdkVersion = A->getValue(); in detectWinSysRoot()
638 sys::path::remove_filename(binDir); // remove lld-link.exe in addClangLibSearchPaths()
701 if (!b->isGCRoot) { in addUndefined()
702 b->isGCRoot = true; in addUndefined()
715 Symbol *mangled = ctx.symtab.findMangle(unmangled->getName()); in mangleMaybe()
721 log(unmangled->getName() + " aliased to " + mangled->getName()); in mangleMaybe()
722 unmangled->weakAlias = ctx.symtab.addUndefined(mangled->getName()); in mangleMaybe()
723 return mangled->getName(); in mangleMaybe()
726 // Windows specific -- find default entry point name.
729 // each of which corresponds to a user-defined "main" function. This function
730 // infers an entry point from a user-defined "main" function.
793 // Reconstructs command line arguments so that so that you can re-run
794 // the same command with the same inputs. This is for --reproduce.
802 switch (arg->getOption().getID()) { in createResponseFile()
814 os << arg->getSpelling() << quote(rewritePath(arg->getValue())) << '\n'; in createResponseFile()
817 StringRef orderFile = arg->getValue(); in createResponseFile()
819 os << arg->getSpelling() << '@' << quote(rewritePath(orderFile)) << '\n'; in createResponseFile()
824 StringRef(arg->getValue()).split("="); in createResponseFile()
825 os << arg->getSpelling() << nameFile.first << '=' in createResponseFile()
834 os << arg->getSpelling() << sys::path::filename(arg->getValue()) << "\n"; in createResponseFile()
857 StringRef(a->getValue()) in parseDebugTypes()
858 .split(types, ',', /*MaxSplit=*/-1, /*KeepEmpty=*/false); in parseDebugTypes()
891 if (arg->getOption().getID() == osFile.getID()) in getMapFile()
892 return arg->getValue(); in getMapFile()
894 assert(arg->getOption().getID() == os.getID()); in getMapFile()
910 // -----+----------------+---------------------+------------------
970 sys::fs::createUniqueFile(path + ".tmp-%%%%%%%%.lib", tmpName)) in createImportLibrary()
982 if ((*oldBuf)->getBuffer() != newBuf->getBuffer()) { in createImportLibrary()
983 oldBuf->reset(); in createImportLibrary()
998 mb->getMemBufferRef(), ctx.config.machine, ctx.config.mingw)); in parseModuleDefs()
1082 if (sec->sym) in parseOrderFile()
1083 set.insert(sec->sym->getName()); in parseOrderFile()
1097 for (StringRef arg : args::getLines(mb->getMemBufferRef())) { in parseOrderFile()
1123 for (Symbol *sym : file->getSymbols()) in parseCallGraphFile()
1125 map[sym->getName()] = sym; in parseCallGraphFile()
1127 auto findSection = [&](StringRef name) -> SectionChunk * { in parseCallGraphFile()
1136 return dyn_cast_or_null<SectionChunk>(dr->getChunk()); in parseCallGraphFile()
1161 if (obj->callgraphSec) { in readCallGraphsFromObjectFiles()
1164 obj->getCOFFObj()->getSectionContents(obj->callgraphSec, contents)); in readCallGraphsFromObjectFiles()
1170 fatal(toString(obj) + ": Expected 32-bit integer"); in readCallGraphsFromObjectFiles()
1172 fatal(toString(obj) + ": Expected 32-bit integer"); in readCallGraphsFromObjectFiles()
1174 fatal(toString(obj) + ": Expected 64-bit integer"); in readCallGraphsFromObjectFiles()
1175 auto *fromSym = dyn_cast_or_null<Defined>(obj->getSymbol(fromIndex)); in readCallGraphsFromObjectFiles()
1176 auto *toSym = dyn_cast_or_null<Defined>(obj->getSymbol(toIndex)); in readCallGraphsFromObjectFiles()
1179 auto *from = dyn_cast_or_null<SectionChunk>(fromSym->getChunk()); in readCallGraphsFromObjectFiles()
1180 auto *to = dyn_cast_or_null<SectionChunk>(toSym->getChunk()); in readCallGraphsFromObjectFiles()
1190 if (SectionChunk *c = dyn_cast_or_null<SectionChunk>(d->getChunk())) in markAddrsig()
1191 c->keepUnique = true; in markAddrsig()
1197 // Exported symbols could be address-significant in other executables or DSOs, in findKeepUniqueSections()
1198 // so we conservatively mark them as address-significant. in findKeepUniqueSections()
1202 // Visit the address-significance table in each object file and mark each in findKeepUniqueSections()
1203 // referenced symbol as address-significant. in findKeepUniqueSections()
1205 ArrayRef<Symbol *> syms = obj->getSymbols(); in findKeepUniqueSections()
1206 if (obj->addrsigSec) { in findKeepUniqueSections()
1209 obj->getCOFFObj()->getSectionContents(obj->addrsigSec, contents)); in findKeepUniqueSections()
1223 // If an object file does not have an address-significance table, in findKeepUniqueSections()
1224 // conservatively mark all of its symbols as address-significant. in findKeepUniqueSections()
1233 // of pdb's output path) and _EXT (expands to the extension of the output
1242 sys::path::extension(ctx.config.outputFile, sys::path::Style::windows); in parsePDBAltPath()
1247 // +--------- cursor ('a...' might be the empty string). in parsePDBAltPath()
1248 // | +----- firstMark in parsePDBAltPath()
1249 // | | +- secondMark in parsePDBAltPath()
1266 buf.append(ctx.config.pdbAltPath.substr(cursor, firstMark - cursor)); in parsePDBAltPath()
1268 ctx.config.pdbAltPath.substr(firstMark, secondMark - firstMark + 1); in parsePDBAltPath()
1293 if (f->isResourceObjFile()) in convertResources()
1311 f->includeResourceChunks(); in convertResources()
1317 f->includeResourceChunks(); in convertResources()
1322 // -export-all-symbols option, so that it happens even when exports are
1324 // -exclude-all-symbols option, so that lld-link behaves like link.exe rather
1340 if (std::optional<StringRef> path = findFile(arg->getValue())) in maybeExportMinGWSymbols()
1345 StringRef(arg->getValue()).split(vec, ','); in maybeExportMinGWSymbols()
1355 if (!def->isGCRoot) { in maybeExportMinGWSymbols()
1356 def->isGCRoot = true; in maybeExportMinGWSymbols()
1361 e.name = def->getName(); in maybeExportMinGWSymbols()
1363 if (Chunk *c = def->getChunk()) in maybeExportMinGWSymbols()
1364 if (!(c->getOutputCharacteristics() & IMAGE_SCN_MEM_EXECUTE)) in maybeExportMinGWSymbols()
1366 s->isUsedInRegularObj = true; in maybeExportMinGWSymbols()
1380 return std::string(arg->getValue()); in getReproduceFile()
1383 SmallString<64> path = StringRef(arg->getValue()); in getReproduceFile()
1404 auto bufOrErr = llvm::MemoryBuffer::getFile(arg->getValue()); in getVFS()
1411 /*DiagHandler*/ nullptr, arg->getValue())) in getVFS()
1433 StringRef(argsArr[1]).equals_insensitive("-lib"))) { in linkerMain()
1443 // Initialize time trace profiler. in linkerMain()
1444 config->timeTraceEnabled = args.hasArg(OPT_time_trace_eq); in linkerMain()
1445 config->timeTraceGranularity = in linkerMain()
1448 if (config->timeTraceEnabled) in linkerMain()
1449 timeTraceProfilerInitialize(config->timeTraceGranularity, argsArr[0]); in linkerMain()
1453 // Parse and evaluate -mllvm options. in linkerMain()
1455 v.push_back("lld-link (LLVM option parsing)"); in linkerMain()
1457 v.push_back(arg->getValue()); in linkerMain()
1458 config->mllvmOpts.emplace_back(arg->getValue()); in linkerMain()
1469 StringRef s = arg->getValue(); in linkerMain()
1471 error(arg->getSpelling() + " number expected, but got " + s); in linkerMain()
1475 config->vfs = getVFS(args); in linkerMain()
1486 StringRef v(arg->getValue()); in linkerMain()
1489 error(arg->getSpelling() + ": expected a positive integer, but got '" + in linkerMain()
1490 arg->getValue() + "'"); in linkerMain()
1492 config->thinLTOJobs = v.str(); in linkerMain()
1496 config->showTiming = true; in linkerMain()
1498 config->showSummary = args.hasArg(OPT_summary); in linkerMain()
1499 config->printSearchPaths = args.hasArg(OPT_print_search_paths); in linkerMain()
1501 // Handle --version, which is an lld extension. This option is a bit odd in linkerMain()
1502 // because it doesn't start with "/", but we deliberately chose "--" to in linkerMain()
1503 // avoid conflict with /version and for compatibility with clang-cl. in linkerMain()
1511 config->mingw = args.hasArg(OPT_lldmingw); in linkerMain()
1512 if (config->mingw) in linkerMain()
1514 " (use --error-limit=0 to see all errors)"; in linkerMain()
1534 config->noEntry = true; in linkerMain()
1544 searchPaths.push_back(arg->getValue()); in linkerMain()
1545 if (!config->mingw) { in linkerMain()
1565 StringRef(arg->getValue()).split(vec, ','); in linkerMain()
1568 config->warnMissingOrderSymbol = false; in linkerMain()
1570 config->warnDebugInfoUnusable = false; in linkerMain()
1572 config->warnLocallyDefinedImported = false; in linkerMain()
1574 config->warnLongSectionNames = false; in linkerMain()
1581 config->outputFile = arg->getValue(); in linkerMain()
1585 config->verbose = true; in linkerMain()
1586 errorHandler().verbose = config->verbose; in linkerMain()
1590 config->forceUnresolved = true; in linkerMain()
1594 config->forceMultiple = true; in linkerMain()
1598 config->forceMultipleRes = true; in linkerMain()
1601 // when -debug:dwarf is requested, handled below). in linkerMain()
1602 if (config->mingw) in linkerMain()
1603 config->warnLongSectionNames = false; in linkerMain()
1611 if (arg->getOption().getID() == OPT_debug) in linkerMain()
1614 str = StringRef(arg->getValue()).lower(); in linkerMain()
1623 config->debug = false; in linkerMain()
1624 config->incremental = false; in linkerMain()
1625 config->includeDwarfChunks = false; in linkerMain()
1626 config->debugGHashes = false; in linkerMain()
1627 config->writeSymtab = false; in linkerMain()
1631 config->debug = true; in linkerMain()
1632 config->incremental = true; in linkerMain()
1633 config->includeDwarfChunks = true; in linkerMain()
1635 config->debugGHashes = true; in linkerMain()
1639 config->debug = true; in linkerMain()
1640 config->incremental = true; in linkerMain()
1641 config->includeDwarfChunks = true; in linkerMain()
1642 config->writeSymtab = true; in linkerMain()
1643 config->warnLongSectionNames = false; in linkerMain()
1646 config->includeDwarfChunks = false; in linkerMain()
1648 config->writeSymtab = true; in linkerMain()
1651 config->writeSymtab = false; in linkerMain()
1659 config->demangle = args.hasFlag(OPT_demangle, OPT_demangle_no, true); in linkerMain()
1662 config->debugTypes = parseDebugTypes(args); in linkerMain()
1665 config->driverUponly = args.hasArg(OPT_driver_uponly) || in linkerMain()
1668 config->driverWdm = args.hasArg(OPT_driver_wdm) || in linkerMain()
1671 config->driver = in linkerMain()
1672 config->driverUponly || config->driverWdm || args.hasArg(OPT_driver); in linkerMain()
1677 config->pdbPath = arg->getValue(); in linkerMain()
1679 config->pdbAltPath = arg->getValue(); in linkerMain()
1681 parsePDBPageSize(arg->getValue()); in linkerMain()
1683 config->natvisFiles = args.getAllArgValues(OPT_natvis); in linkerMain()
1689 config->namedStreams[name] = file; in linkerMain()
1694 config->pdbSourcePath = arg->getValue(); in linkerMain()
1704 config->noEntry = true; in linkerMain()
1711 config->dll = true; in linkerMain()
1712 config->manifestID = 2; in linkerMain()
1720 dynamicBaseArg->getOption().getID() == OPT_dynamicbase_no) in linkerMain()
1721 config->dynamicBase = false; in linkerMain()
1729 dynamicBaseArg->getOption().getID() == OPT_dynamicbase) { in linkerMain()
1732 config->relocatable = false; in linkerMain()
1733 config->dynamicBase = false; in linkerMain()
1738 config->appContainer = in linkerMain()
1745 config->machine = getMachineType(arg->getValue()); in linkerMain()
1746 if (config->machine == IMAGE_FILE_MACHINE_UNKNOWN) in linkerMain()
1747 fatal(Twine("unknown /machine argument: ") + arg->getValue()); in linkerMain()
1756 config->noDefaultLibs.insert(findLib(arg->getValue()).lower()); in linkerMain()
1761 config->noDefaultLibAll = true; in linkerMain()
1765 parseNumbers(arg->getValue(), &config->imageBase); in linkerMain()
1769 parseNumbers(arg->getValue(), &config->fileAlign); in linkerMain()
1770 if (!isPowerOf2_64(config->fileAlign)) in linkerMain()
1771 error("/filealign: not a power of two: " + Twine(config->fileAlign)); in linkerMain()
1776 parseNumbers(arg->getValue(), &config->stackReserve, &config->stackCommit); in linkerMain()
1780 parseGuard(arg->getValue()); in linkerMain()
1784 parseNumbers(arg->getValue(), &config->heapReserve, &config->heapCommit); in linkerMain()
1788 parseVersion(arg->getValue(), &config->majorImageVersion, in linkerMain()
1789 &config->minorImageVersion); in linkerMain()
1793 parseSubsystem(arg->getValue(), &config->subsystem, in linkerMain()
1794 &config->majorSubsystemVersion, in linkerMain()
1795 &config->minorSubsystemVersion); in linkerMain()
1799 parseVersion(arg->getValue(), &config->majorOSVersion, in linkerMain()
1800 &config->minorOSVersion); in linkerMain()
1802 config->majorOSVersion = config->majorSubsystemVersion; in linkerMain()
1803 config->minorOSVersion = config->minorSubsystemVersion; in linkerMain()
1808 if (arg->getOption().getID() == OPT_repro) { in linkerMain()
1809 config->timestamp = 0; in linkerMain()
1810 config->repro = true; in linkerMain()
1812 config->repro = false; in linkerMain()
1813 StringRef value(arg->getValue()); in linkerMain()
1814 if (value.getAsInteger(0, config->timestamp)) in linkerMain()
1816 ". Expected 32-bit integer"); in linkerMain()
1819 config->repro = false; in linkerMain()
1823 if (value.getAsInteger(0, config->timestamp)) in linkerMain()
1825 ". Expected 32-bit integer"); in linkerMain()
1827 config->timestamp = time(nullptr); in linkerMain()
1833 parseAlternateName(arg->getValue()); in linkerMain()
1837 addUndefined(arg->getValue()); in linkerMain()
1841 config->implib = arg->getValue(); in linkerMain()
1843 config->noimplib = args.hasArg(OPT_noimplib); in linkerMain()
1854 std::string str = StringRef(arg->getValue()).lower(); in linkerMain()
1877 if (s.getAsInteger(10, config->ltoo) || config->ltoo > 3) in linkerMain()
1880 config->ltoCgo.emplace(); in linkerMain()
1881 if (s.getAsInteger(10, *config->ltoCgo) || *config->ltoCgo > 3) in linkerMain()
1886 config->thinLTOJobs = s.str(); in linkerMain()
1888 if (s.getAsInteger(10, config->ltoPartitions) || in linkerMain()
1889 config->ltoPartitions == 0) in linkerMain()
1898 config->doGC = doGC; in linkerMain()
1899 config->doICF = *icfLevel; in linkerMain()
1900 config->tailMerge = in linkerMain()
1901 (tailMerge == 1 && config->doICF != ICFLevel::None) || tailMerge == 2; in linkerMain()
1902 config->ltoDebugPassManager = ltoDebugPM; in linkerMain()
1906 config->saveTemps = true; in linkerMain()
1910 StringRef s = arg->getValue(); in linkerMain()
1912 config->emit = EmitKind::Obj; in linkerMain()
1914 config->emit = EmitKind::LLVM; in linkerMain()
1916 config->emit = EmitKind::ASM; in linkerMain()
1921 // Handle /kill-at in linkerMain()
1923 config->killAt = true; in linkerMain()
1927 config->ltoCache = arg->getValue(); in linkerMain()
1931 config->ltoCachePolicy = CHECK( in linkerMain()
1932 parseCachePruningPolicy(arg->getValue()), in linkerMain()
1933 Twine("/lldltocachepolicy: invalid cache policy: ") + arg->getValue()); in linkerMain()
1937 checkFailIfMismatch(arg->getValue(), nullptr); in linkerMain()
1941 parseMerge(arg->getValue()); in linkerMain()
1952 if (isArm64EC(config->machine)) in linkerMain()
1955 if (config->mingw) { in linkerMain()
1963 parseSection(arg->getValue()); in linkerMain()
1967 parseNumbers(arg->getValue(), &config->align); in linkerMain()
1968 if (!isPowerOf2_64(config->align)) in linkerMain()
1969 error("/align: not a power of two: " + StringRef(arg->getValue())); in linkerMain()
1976 parseAligncomm(arg->getValue()); in linkerMain()
1980 config->manifestDependencies.insert(arg->getValue()); in linkerMain()
1984 if (arg->getOption().getID() == OPT_manifest) in linkerMain()
1985 config->manifest = Configuration::SideBySide; in linkerMain()
1987 parseManifest(arg->getValue()); in linkerMain()
1992 parseManifestUAC(arg->getValue()); in linkerMain()
1996 config->manifestFile = arg->getValue(); in linkerMain()
2000 config->manifestInput.push_back(arg->getValue()); in linkerMain()
2002 if (!config->manifestInput.empty() && in linkerMain()
2003 config->manifest != Configuration::Embed) { in linkerMain()
2008 config->dwoDir = args.getLastArgValue(OPT_dwodir); in linkerMain()
2010 config->thinLTOEmitImportsFiles = args.hasArg(OPT_thinlto_emit_imports_files); in linkerMain()
2011 config->thinLTOIndexOnly = args.hasArg(OPT_thinlto_index_only) || in linkerMain()
2013 config->thinLTOIndexOnlyArg = in linkerMain()
2015 std::tie(config->thinLTOPrefixReplaceOld, config->thinLTOPrefixReplaceNew, in linkerMain()
2016 config->thinLTOPrefixReplaceNativeObject) = in linkerMain()
2018 config->thinLTOObjectSuffixReplace = in linkerMain()
2020 config->ltoObjPath = args.getLastArgValue(OPT_lto_obj_path); in linkerMain()
2021 config->ltoCSProfileGenerate = args.hasArg(OPT_lto_cs_profile_generate); in linkerMain()
2022 config->ltoCSProfileFile = args.getLastArgValue(OPT_lto_cs_profile_file); in linkerMain()
2023 config->ltoSampleProfileName = args.getLastArgValue(OPT_lto_sample_profile); in linkerMain()
2025 config->ltoPGOWarnMismatch = args.hasFlag(OPT_lto_pgo_warn_mismatch, in linkerMain()
2027 config->allowBind = args.hasFlag(OPT_allowbind, OPT_allowbind_no, true); in linkerMain()
2028 config->allowIsolation = in linkerMain()
2030 config->incremental = in linkerMain()
2032 !config->doGC && config->doICF == ICFLevel::None && in linkerMain()
2034 config->integrityCheck = in linkerMain()
2036 config->cetCompat = args.hasFlag(OPT_cetcompat, OPT_cetcompat_no, false); in linkerMain()
2037 config->nxCompat = args.hasFlag(OPT_nxcompat, OPT_nxcompat_no, true); in linkerMain()
2039 parseSwaprun(arg->getValue()); in linkerMain()
2040 config->terminalServerAware = in linkerMain()
2041 !config->dll && args.hasFlag(OPT_tsaware, OPT_tsaware_no, true); in linkerMain()
2042 config->autoImport = in linkerMain()
2043 args.hasFlag(OPT_auto_import, OPT_auto_import_no, config->mingw); in linkerMain()
2044 config->pseudoRelocs = args.hasFlag( in linkerMain()
2045 OPT_runtime_pseudo_reloc, OPT_runtime_pseudo_reloc_no, config->mingw); in linkerMain()
2046 config->callGraphProfileSort = args.hasFlag( in linkerMain()
2048 config->stdcallFixup = in linkerMain()
2049 args.hasFlag(OPT_stdcall_fixup, OPT_stdcall_fixup_no, config->mingw); in linkerMain()
2050 config->warnStdcallFixup = !args.hasArg(OPT_stdcall_fixup); in linkerMain()
2051 config->allowDuplicateWeak = in linkerMain()
2053 OPT_lld_allow_duplicate_weak_no, config->mingw); in linkerMain()
2058 if (config->incremental && args.hasArg(OPT_profile)) { in linkerMain()
2060 config->incremental = false; in linkerMain()
2063 if (config->incremental && args.hasArg(OPT_order)) { in linkerMain()
2065 config->incremental = false; in linkerMain()
2068 if (config->incremental && config->doGC) { in linkerMain()
2071 config->incremental = false; in linkerMain()
2074 if (config->incremental && config->doICF != ICFLevel::None) { in linkerMain()
2077 config->incremental = false; in linkerMain()
2085 if (std::optional<StringRef> path = findFile(arg->getValue())) in linkerMain()
2093 auto isWholeArchive = [&](StringRef path) -> bool { in linkerMain()
2108 switch (arg->getOption().getID()) { in linkerMain()
2111 error("stray " + arg->getSpelling()); in linkerMain()
2116 error("nested " + arg->getSpelling()); in linkerMain()
2120 if (std::optional<StringRef> path = findFileIfNew(arg->getValue())) in linkerMain()
2124 if (std::optional<StringRef> path = findFileIfNew(arg->getValue())) in linkerMain()
2141 if (config->machine == IMAGE_FILE_MACHINE_UNKNOWN) { in linkerMain()
2143 config->machine = AMD64; in linkerMain()
2146 config->wordsize = config->is64() ? 8 : 4; in linkerMain()
2148 if (config->printSearchPaths) { in linkerMain()
2165 if (std::optional<StringRef> path = findLibIfNew(arg->getValue())) in linkerMain()
2173 config->writeCheckSum = true; in linkerMain()
2176 if (config->machine == I386) { in linkerMain()
2177 config->safeSEH = args.hasFlag(OPT_safeseh, OPT_safeseh_no, !config->mingw); in linkerMain()
2178 config->noSEH = args.hasArg(OPT_noseh); in linkerMain()
2192 tar->append("response.txt", in linkerMain()
2198 config->largeAddressAware = args.hasFlag( in linkerMain()
2199 OPT_largeaddressaware, OPT_largeaddressaware_no, config->is64()); in linkerMain()
2202 config->highEntropyVA = in linkerMain()
2203 config->is64() && in linkerMain()
2206 if (!config->dynamicBase && in linkerMain()
2207 (config->machine == ARMNT || isAnyArm64(config->machine))) in linkerMain()
2209 machineToStr(config->machine)); in linkerMain()
2215 Export e = parseExport(arg->getValue()); in linkerMain()
2216 if (config->machine == I386) { in linkerMain()
2222 config->exports.push_back(e); in linkerMain()
2229 parseModuleDefs(arg->getValue()); in linkerMain()
2235 if (!config->noimplib) in linkerMain()
2240 // Windows specific -- if no /subsystem is given, we need to infer in linkerMain()
2243 if (config->subsystem == IMAGE_SUBSYSTEM_UNKNOWN) { in linkerMain()
2245 config->subsystem = inferSubsystem(); in linkerMain()
2246 if (config->subsystem == IMAGE_SUBSYSTEM_UNKNOWN) in linkerMain()
2254 if (!arg->getValue()[0]) in linkerMain()
2256 config->entry = addUndefined(mangle(arg->getValue())); in linkerMain()
2257 } else if (!config->entry && !config->noEntry) { in linkerMain()
2259 StringRef s = (config->machine == I386) ? "__DllMainCRTStartup@12" in linkerMain()
2261 config->entry = addUndefined(s); in linkerMain()
2262 } else if (config->driverWdm) { in linkerMain()
2264 config->entry = addUndefined(mangle("_NtProcessStartup")); in linkerMain()
2266 // Windows specific -- If entry point name is not given, we need to in linkerMain()
2267 // infer that from user-defined entry name. in linkerMain()
2271 config->entry = addUndefined(s); in linkerMain()
2281 config->delayLoads.insert(StringRef(arg->getValue()).lower()); in linkerMain()
2282 if (config->machine == I386) { in linkerMain()
2283 config->delayLoadHelper = addUndefined("___delayLoadHelper2@8"); in linkerMain()
2285 config->delayLoadHelper = addUndefined("__delayLoadHelper2"); in linkerMain()
2291 if (config->outputFile.empty()) { in linkerMain()
2292 config->outputFile = getOutputPath( in linkerMain()
2293 (*args.filtered(OPT_INPUT, OPT_wholearchive_file).begin())->getValue(), in linkerMain()
2294 config->dll, config->driver); in linkerMain()
2298 if (auto e = tryCreateFile(config->outputFile)) { in linkerMain()
2299 error("cannot open output file " + config->outputFile + ": " + e.message()); in linkerMain()
2303 config->lldmapFile = getMapFile(args, OPT_lldmap, OPT_lldmap_file); in linkerMain()
2304 config->mapFile = getMapFile(args, OPT_map, OPT_map_file); in linkerMain()
2306 if (config->mapFile != "" && args.hasArg(OPT_map_info)) { in linkerMain()
2308 std::string s = StringRef(arg->getValue()).lower(); in linkerMain()
2310 config->mapInfo = true; in linkerMain()
2316 if (config->lldmapFile != "" && config->lldmapFile == config->mapFile) { in linkerMain()
2317 warn("/lldmap and /map have the same output file '" + config->mapFile + in linkerMain()
2319 config->lldmapFile.clear(); in linkerMain()
2325 config->buildIDHash = BuildIDHash::Binary; in linkerMain()
2329 if (config->pdbPath.empty()) { in linkerMain()
2330 config->pdbPath = config->outputFile; in linkerMain()
2331 sys::path::replace_extension(config->pdbPath, ".pdb"); in linkerMain()
2334 // The embedded PDB path should be the absolute path to the PDB if no in linkerMain()
2336 if (config->pdbAltPath.empty()) { in linkerMain()
2337 config->pdbAltPath = config->pdbPath; in linkerMain()
2342 sys::fs::make_absolute(config->pdbAltPath); in linkerMain()
2343 sys::path::remove_dots(config->pdbAltPath); in linkerMain()
2348 config->buildIDHash = BuildIDHash::PDB; in linkerMain()
2352 if (config->imageBase == uint64_t(-1)) in linkerMain()
2353 config->imageBase = getDefaultImageBase(); in linkerMain()
2356 if (config->machine == I386) { in linkerMain()
2374 if (isArm64EC(config->machine)) { in linkerMain()
2381 if (config->pseudoRelocs) { in linkerMain()
2385 if (config->mingw) { in linkerMain()
2389 if (config->debug || config->buildIDHash != BuildIDHash::None) in linkerMain()
2399 // Windows specific -- if entry point is not found, in linkerMain()
2401 if (config->entry) in linkerMain()
2402 mangleMaybe(config->entry); in linkerMain()
2404 // Windows specific -- Make sure we resolve all dllexported symbols. in linkerMain()
2405 for (Export &e : config->exports) { in linkerMain()
2415 for (auto pair : config->alternateNames) { in linkerMain()
2422 if (!u->weakAlias) in linkerMain()
2423 u->weakAlias = ctx.symtab.addUndefined(to); in linkerMain()
2433 ctx.bitcodeFileInstances.front()->obj->getTargetTriple()); in linkerMain()
2438 // Windows specific -- if __load_config_used can be resolved, resolve it. in linkerMain()
2445 if (isa_and_nonnull<LazyArchive>(ctx.symtab.find(arg->getValue()))) in linkerMain()
2446 addUndefined(arg->getValue()); in linkerMain()
2451 // Create wrapped symbols for -wrap option. in linkerMain()
2458 if (config->autoImport || config->stdcallFixup) { in linkerMain()
2484 // If we are going to do codegen for link-time optimization, check for in linkerMain()
2487 if (!ctx.bitcodeFileInstances.empty() && !config->forceUnresolved) in linkerMain()
2492 config->hadExplicitExports = !config->exports.empty(); in linkerMain()
2493 if (config->mingw) { in linkerMain()
2500 // link those files (unless -thinlto-index-only was given, in which case we in linkerMain()
2506 config->gcroot.push_back(d); in linkerMain()
2508 // If -thinlto-index-only is given, we should create only "index in linkerMain()
2512 if (config->emit != EmitKind::Obj || config->thinLTOIndexOnly) in linkerMain()
2519 // Apply symbol renames for -wrap. in linkerMain()
2528 if (config->mingw) { in linkerMain()
2538 if (isCrtend(file->getName())) { in linkerMain()
2546 // Windows specific -- when we are creating a .dll file, we also in linkerMain()
2548 // -implib option is given explicitly, for compatibility with GNU ld. in linkerMain()
2549 if (!config->exports.empty() || config->dll) { in linkerMain()
2552 if (!config->noimplib && (!config->mingw || !config->implib.empty())) in linkerMain()
2557 // Handle /output-def (MinGW specific). in linkerMain()
2559 writeDefFile(arg->getValue(), config->exports); in linkerMain()
2562 for (auto pair : config->alignComm) { in linkerMain()
2578 CommonChunk *c = dc->getChunk(); in linkerMain()
2579 c->setAlignment(std::max(c->getAlignment(), alignment)); in linkerMain()
2582 // Windows specific -- Create an embedded or side-by-side manifest. in linkerMain()
2585 if (config->manifest == Configuration::Embed) in linkerMain()
2587 else if (config->manifest == Configuration::SideBySide || in linkerMain()
2588 (config->manifest == Configuration::Default && in linkerMain()
2589 !config->manifestDependencies.empty())) in linkerMain()
2597 error("/order and /call-graph-order-file may not be used together"); in linkerMain()
2598 parseOrderFile(arg->getValue()); in linkerMain()
2599 config->callGraphProfileSort = false; in linkerMain()
2602 // Handle /call-graph-ordering-file and /call-graph-profile-sort (default on). in linkerMain()
2603 if (config->callGraphProfileSort) { in linkerMain()
2606 parseCallGraphFile(arg->getValue()); in linkerMain()
2611 // Handle /print-symbol-order. in linkerMain()
2613 config->printSymbolOrder = arg->getValue(); in linkerMain()
2618 if (config->doGC) { in linkerMain()
2619 if (config->mingw) { in linkerMain()
2629 if (d && !d->isGCRoot) { in linkerMain()
2630 d->isGCRoot = true; in linkerMain()
2631 config->gcroot.push_back(d); in linkerMain()
2643 if (config->doICF != ICFLevel::None) { in linkerMain()
2653 if (config->showTiming) in linkerMain()
2656 if (config->timeTraceEnabled) { in linkerMain()
2661 args.getLastArgValue(OPT_time_trace_eq).str(), config->outputFile)); in linkerMain()