1 //===- DriverUtils.cpp ----------------------------------------------------===// 2 // 3 // The LLVM Linker 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file contains utility functions for the driver. Because there 11 // are so many small functions, we created this separate file to make 12 // Driver.cpp less cluttered. 13 // 14 //===----------------------------------------------------------------------===// 15 16 #include "Config.h" 17 #include "Driver.h" 18 #include "Error.h" 19 #include "Symbols.h" 20 #include "llvm/ADT/Optional.h" 21 #include "llvm/ADT/StringSwitch.h" 22 #include "llvm/Object/COFF.h" 23 #include "llvm/Option/Arg.h" 24 #include "llvm/Option/ArgList.h" 25 #include "llvm/Option/Option.h" 26 #include "llvm/Support/CommandLine.h" 27 #include "llvm/Support/FileUtilities.h" 28 #include "llvm/Support/Process.h" 29 #include "llvm/Support/Program.h" 30 #include "llvm/Support/raw_ostream.h" 31 #include <memory> 32 33 using namespace llvm::COFF; 34 using namespace llvm; 35 using llvm::cl::ExpandResponseFiles; 36 using llvm::cl::TokenizeWindowsCommandLine; 37 using llvm::sys::Process; 38 39 namespace lld { 40 namespace coff { 41 namespace { 42 43 class Executor { 44 public: 45 explicit Executor(StringRef S) : Saver(Alloc), Prog(Saver.save(S)) {} 46 void add(StringRef S) { Args.push_back(Saver.save(S)); } 47 void add(std::string &S) { Args.push_back(Saver.save(S)); } 48 void add(Twine S) { Args.push_back(Saver.save(S)); } 49 void add(const char *S) { Args.push_back(Saver.save(S)); } 50 51 void run() { 52 ErrorOr<std::string> ExeOrErr = llvm::sys::findProgramByName(Prog); 53 if (auto EC = ExeOrErr.getError()) 54 fatal(EC, "unable to find " + Prog + " in PATH: "); 55 const char *Exe = Saver.save(*ExeOrErr); 56 Args.insert(Args.begin(), Exe); 57 Args.push_back(nullptr); 58 if (llvm::sys::ExecuteAndWait(Args[0], Args.data()) != 0) { 59 for (const char *S : Args) 60 if (S) 61 llvm::errs() << S << " "; 62 fatal("ExecuteAndWait failed"); 63 } 64 } 65 66 private: 67 llvm::BumpPtrAllocator Alloc; 68 llvm::StringSaver Saver; 69 StringRef Prog; 70 std::vector<const char *> Args; 71 }; 72 73 } // anonymous namespace 74 75 // Returns /machine's value. 76 MachineTypes getMachineType(StringRef S) { 77 MachineTypes MT = StringSwitch<MachineTypes>(S.lower()) 78 .Case("x64", AMD64) 79 .Case("amd64", AMD64) 80 .Case("x86", I386) 81 .Case("i386", I386) 82 .Case("arm", ARMNT) 83 .Default(IMAGE_FILE_MACHINE_UNKNOWN); 84 if (MT != IMAGE_FILE_MACHINE_UNKNOWN) 85 return MT; 86 fatal("unknown /machine argument: " + S); 87 } 88 89 StringRef machineToStr(MachineTypes MT) { 90 switch (MT) { 91 case ARMNT: 92 return "arm"; 93 case AMD64: 94 return "x64"; 95 case I386: 96 return "x86"; 97 default: 98 llvm_unreachable("unknown machine type"); 99 } 100 } 101 102 // Parses a string in the form of "<integer>[,<integer>]". 103 void parseNumbers(StringRef Arg, uint64_t *Addr, uint64_t *Size) { 104 StringRef S1, S2; 105 std::tie(S1, S2) = Arg.split(','); 106 if (S1.getAsInteger(0, *Addr)) 107 fatal("invalid number: " + S1); 108 if (Size && !S2.empty() && S2.getAsInteger(0, *Size)) 109 fatal("invalid number: " + S2); 110 } 111 112 // Parses a string in the form of "<integer>[.<integer>]". 113 // If second number is not present, Minor is set to 0. 114 void parseVersion(StringRef Arg, uint32_t *Major, uint32_t *Minor) { 115 StringRef S1, S2; 116 std::tie(S1, S2) = Arg.split('.'); 117 if (S1.getAsInteger(0, *Major)) 118 fatal("invalid number: " + S1); 119 *Minor = 0; 120 if (!S2.empty() && S2.getAsInteger(0, *Minor)) 121 fatal("invalid number: " + S2); 122 } 123 124 // Parses a string in the form of "<subsystem>[,<integer>[.<integer>]]". 125 void parseSubsystem(StringRef Arg, WindowsSubsystem *Sys, uint32_t *Major, 126 uint32_t *Minor) { 127 StringRef SysStr, Ver; 128 std::tie(SysStr, Ver) = Arg.split(','); 129 *Sys = StringSwitch<WindowsSubsystem>(SysStr.lower()) 130 .Case("boot_application", IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION) 131 .Case("console", IMAGE_SUBSYSTEM_WINDOWS_CUI) 132 .Case("efi_application", IMAGE_SUBSYSTEM_EFI_APPLICATION) 133 .Case("efi_boot_service_driver", IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER) 134 .Case("efi_rom", IMAGE_SUBSYSTEM_EFI_ROM) 135 .Case("efi_runtime_driver", IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) 136 .Case("native", IMAGE_SUBSYSTEM_NATIVE) 137 .Case("posix", IMAGE_SUBSYSTEM_POSIX_CUI) 138 .Case("windows", IMAGE_SUBSYSTEM_WINDOWS_GUI) 139 .Default(IMAGE_SUBSYSTEM_UNKNOWN); 140 if (*Sys == IMAGE_SUBSYSTEM_UNKNOWN) 141 fatal("unknown subsystem: " + SysStr); 142 if (!Ver.empty()) 143 parseVersion(Ver, Major, Minor); 144 } 145 146 // Parse a string of the form of "<from>=<to>". 147 // Results are directly written to Config. 148 void parseAlternateName(StringRef S) { 149 StringRef From, To; 150 std::tie(From, To) = S.split('='); 151 if (From.empty() || To.empty()) 152 fatal("/alternatename: invalid argument: " + S); 153 auto It = Config->AlternateNames.find(From); 154 if (It != Config->AlternateNames.end() && It->second != To) 155 fatal("/alternatename: conflicts: " + S); 156 Config->AlternateNames.insert(It, std::make_pair(From, To)); 157 } 158 159 // Parse a string of the form of "<from>=<to>". 160 // Results are directly written to Config. 161 void parseMerge(StringRef S) { 162 StringRef From, To; 163 std::tie(From, To) = S.split('='); 164 if (From.empty() || To.empty()) 165 fatal("/merge: invalid argument: " + S); 166 auto Pair = Config->Merge.insert(std::make_pair(From, To)); 167 bool Inserted = Pair.second; 168 if (!Inserted) { 169 StringRef Existing = Pair.first->second; 170 if (Existing != To) 171 llvm::errs() << "warning: " << S << ": already merged into " 172 << Existing << "\n"; 173 } 174 } 175 176 static uint32_t parseSectionAttributes(StringRef S) { 177 uint32_t Ret = 0; 178 for (char C : S.lower()) { 179 switch (C) { 180 case 'd': 181 Ret |= IMAGE_SCN_MEM_DISCARDABLE; 182 break; 183 case 'e': 184 Ret |= IMAGE_SCN_MEM_EXECUTE; 185 break; 186 case 'k': 187 Ret |= IMAGE_SCN_MEM_NOT_CACHED; 188 break; 189 case 'p': 190 Ret |= IMAGE_SCN_MEM_NOT_PAGED; 191 break; 192 case 'r': 193 Ret |= IMAGE_SCN_MEM_READ; 194 break; 195 case 's': 196 Ret |= IMAGE_SCN_MEM_SHARED; 197 break; 198 case 'w': 199 Ret |= IMAGE_SCN_MEM_WRITE; 200 break; 201 default: 202 fatal("/section: invalid argument: " + S); 203 } 204 } 205 return Ret; 206 } 207 208 // Parses /section option argument. 209 void parseSection(StringRef S) { 210 StringRef Name, Attrs; 211 std::tie(Name, Attrs) = S.split(','); 212 if (Name.empty() || Attrs.empty()) 213 fatal("/section: invalid argument: " + S); 214 Config->Section[Name] = parseSectionAttributes(Attrs); 215 } 216 217 // Parses a string in the form of "EMBED[,=<integer>]|NO". 218 // Results are directly written to Config. 219 void parseManifest(StringRef Arg) { 220 if (Arg.equals_lower("no")) { 221 Config->Manifest = Configuration::No; 222 return; 223 } 224 if (!Arg.startswith_lower("embed")) 225 fatal("invalid option " + Arg); 226 Config->Manifest = Configuration::Embed; 227 Arg = Arg.substr(strlen("embed")); 228 if (Arg.empty()) 229 return; 230 if (!Arg.startswith_lower(",id=")) 231 fatal("invalid option " + Arg); 232 Arg = Arg.substr(strlen(",id=")); 233 if (Arg.getAsInteger(0, Config->ManifestID)) 234 fatal("invalid option " + Arg); 235 } 236 237 // Parses a string in the form of "level=<string>|uiAccess=<string>|NO". 238 // Results are directly written to Config. 239 void parseManifestUAC(StringRef Arg) { 240 if (Arg.equals_lower("no")) { 241 Config->ManifestUAC = false; 242 return; 243 } 244 for (;;) { 245 Arg = Arg.ltrim(); 246 if (Arg.empty()) 247 return; 248 if (Arg.startswith_lower("level=")) { 249 Arg = Arg.substr(strlen("level=")); 250 std::tie(Config->ManifestLevel, Arg) = Arg.split(" "); 251 continue; 252 } 253 if (Arg.startswith_lower("uiaccess=")) { 254 Arg = Arg.substr(strlen("uiaccess=")); 255 std::tie(Config->ManifestUIAccess, Arg) = Arg.split(" "); 256 continue; 257 } 258 fatal("invalid option " + Arg); 259 } 260 } 261 262 // Quote each line with "". Existing double-quote is converted 263 // to two double-quotes. 264 static void quoteAndPrint(raw_ostream &Out, StringRef S) { 265 while (!S.empty()) { 266 StringRef Line; 267 std::tie(Line, S) = S.split("\n"); 268 if (Line.empty()) 269 continue; 270 Out << '\"'; 271 for (int I = 0, E = Line.size(); I != E; ++I) { 272 if (Line[I] == '\"') { 273 Out << "\"\""; 274 } else { 275 Out << Line[I]; 276 } 277 } 278 Out << "\"\n"; 279 } 280 } 281 282 // Create the default manifest file as a temporary file. 283 static std::string createDefaultXml() { 284 // Create a temporary file. 285 SmallString<128> Path; 286 if (auto EC = sys::fs::createTemporaryFile("tmp", "manifest", Path)) 287 fatal(EC, "cannot create a temporary file"); 288 289 // Open the temporary file for writing. 290 std::error_code EC; 291 llvm::raw_fd_ostream OS(Path, EC, sys::fs::F_Text); 292 if (EC) 293 fatal(EC, "failed to open " + Path); 294 295 // Emit the XML. Note that we do *not* verify that the XML attributes are 296 // syntactically correct. This is intentional for link.exe compatibility. 297 OS << "<?xml version=\"1.0\" standalone=\"yes\"?>\n" 298 << "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\"\n" 299 << " manifestVersion=\"1.0\">\n"; 300 if (Config->ManifestUAC) { 301 OS << " <trustInfo>\n" 302 << " <security>\n" 303 << " <requestedPrivileges>\n" 304 << " <requestedExecutionLevel level=" << Config->ManifestLevel 305 << " uiAccess=" << Config->ManifestUIAccess << "/>\n" 306 << " </requestedPrivileges>\n" 307 << " </security>\n" 308 << " </trustInfo>\n"; 309 if (!Config->ManifestDependency.empty()) { 310 OS << " <dependency>\n" 311 << " <dependentAssembly>\n" 312 << " <assemblyIdentity " << Config->ManifestDependency << " />\n" 313 << " </dependentAssembly>\n" 314 << " </dependency>\n"; 315 } 316 } 317 OS << "</assembly>\n"; 318 OS.close(); 319 return StringRef(Path); 320 } 321 322 static std::string readFile(StringRef Path) { 323 std::unique_ptr<MemoryBuffer> MB = 324 check(MemoryBuffer::getFile(Path), "could not open " + Path); 325 std::unique_ptr<MemoryBuffer> Buf(std::move(MB)); 326 return Buf->getBuffer(); 327 } 328 329 static std::string createManifestXml() { 330 // Create the default manifest file. 331 std::string Path1 = createDefaultXml(); 332 if (Config->ManifestInput.empty()) 333 return readFile(Path1); 334 335 // If manifest files are supplied by the user using /MANIFESTINPUT 336 // option, we need to merge them with the default manifest. 337 SmallString<128> Path2; 338 if (auto EC = sys::fs::createTemporaryFile("tmp", "manifest", Path2)) 339 fatal(EC, "cannot create a temporary file"); 340 FileRemover Remover1(Path1); 341 FileRemover Remover2(Path2); 342 343 Executor E("mt.exe"); 344 E.add("/manifest"); 345 E.add(Path1); 346 for (StringRef Filename : Config->ManifestInput) { 347 E.add("/manifest"); 348 E.add(Filename); 349 } 350 E.add("/nologo"); 351 E.add("/out:" + StringRef(Path2)); 352 E.run(); 353 return readFile(Path2); 354 } 355 356 // Create a resource file containing a manifest XML. 357 std::unique_ptr<MemoryBuffer> createManifestRes() { 358 // Create a temporary file for the resource script file. 359 SmallString<128> RCPath; 360 if (auto EC = sys::fs::createTemporaryFile("tmp", "rc", RCPath)) 361 fatal(EC, "cannot create a temporary file"); 362 FileRemover RCRemover(RCPath); 363 364 // Open the temporary file for writing. 365 std::error_code EC; 366 llvm::raw_fd_ostream Out(RCPath, EC, sys::fs::F_Text); 367 if (EC) 368 fatal(EC, "failed to open " + RCPath); 369 370 // Write resource script to the RC file. 371 Out << "#define LANG_ENGLISH 9\n" 372 << "#define SUBLANG_DEFAULT 1\n" 373 << "#define APP_MANIFEST " << Config->ManifestID << "\n" 374 << "#define RT_MANIFEST 24\n" 375 << "LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT\n" 376 << "APP_MANIFEST RT_MANIFEST {\n"; 377 quoteAndPrint(Out, createManifestXml()); 378 Out << "}\n"; 379 Out.close(); 380 381 // Create output resource file. 382 SmallString<128> ResPath; 383 if (auto EC = sys::fs::createTemporaryFile("tmp", "res", ResPath)) 384 fatal(EC, "cannot create a temporary file"); 385 386 Executor E("rc.exe"); 387 E.add("/fo"); 388 E.add(ResPath.str()); 389 E.add("/nologo"); 390 E.add(RCPath.str()); 391 E.run(); 392 return check(MemoryBuffer::getFile(ResPath), "could not open " + ResPath); 393 } 394 395 void createSideBySideManifest() { 396 std::string Path = Config->ManifestFile; 397 if (Path == "") 398 Path = Config->OutputFile + ".manifest"; 399 std::error_code EC; 400 llvm::raw_fd_ostream Out(Path, EC, llvm::sys::fs::F_Text); 401 if (EC) 402 fatal(EC, "failed to create manifest"); 403 Out << createManifestXml(); 404 } 405 406 // Parse a string in the form of 407 // "<name>[=<internalname>][,@ordinal[,NONAME]][,DATA][,PRIVATE]" 408 // or "<name>=<dllname>.<name>". 409 // Used for parsing /export arguments. 410 Export parseExport(StringRef Arg) { 411 Export E; 412 StringRef Rest; 413 std::tie(E.Name, Rest) = Arg.split(","); 414 if (E.Name.empty()) 415 goto err; 416 417 if (E.Name.find('=') != StringRef::npos) { 418 StringRef X, Y; 419 std::tie(X, Y) = E.Name.split("="); 420 421 // If "<name>=<dllname>.<name>". 422 if (Y.find(".") != StringRef::npos) { 423 E.Name = X; 424 E.ForwardTo = Y; 425 return E; 426 } 427 428 E.ExtName = X; 429 E.Name = Y; 430 if (E.Name.empty()) 431 goto err; 432 } 433 434 // If "<name>=<internalname>[,@ordinal[,NONAME]][,DATA][,PRIVATE]" 435 while (!Rest.empty()) { 436 StringRef Tok; 437 std::tie(Tok, Rest) = Rest.split(","); 438 if (Tok.equals_lower("noname")) { 439 if (E.Ordinal == 0) 440 goto err; 441 E.Noname = true; 442 continue; 443 } 444 if (Tok.equals_lower("data")) { 445 E.Data = true; 446 continue; 447 } 448 if (Tok.equals_lower("private")) { 449 E.Private = true; 450 continue; 451 } 452 if (Tok.startswith("@")) { 453 int32_t Ord; 454 if (Tok.substr(1).getAsInteger(0, Ord)) 455 goto err; 456 if (Ord <= 0 || 65535 < Ord) 457 goto err; 458 E.Ordinal = Ord; 459 continue; 460 } 461 goto err; 462 } 463 return E; 464 465 err: 466 fatal("invalid /export: " + Arg); 467 } 468 469 static StringRef undecorate(StringRef Sym) { 470 if (Config->Machine != I386) 471 return Sym; 472 return Sym.startswith("_") ? Sym.substr(1) : Sym; 473 } 474 475 // Performs error checking on all /export arguments. 476 // It also sets ordinals. 477 void fixupExports() { 478 // Symbol ordinals must be unique. 479 std::set<uint16_t> Ords; 480 for (Export &E : Config->Exports) { 481 if (E.Ordinal == 0) 482 continue; 483 if (!Ords.insert(E.Ordinal).second) 484 fatal("duplicate export ordinal: " + E.Name); 485 } 486 487 for (Export &E : Config->Exports) { 488 if (!E.ForwardTo.empty()) { 489 E.SymbolName = E.Name; 490 } else if (Undefined *U = cast_or_null<Undefined>(E.Sym->WeakAlias)) { 491 E.SymbolName = U->getName(); 492 } else { 493 E.SymbolName = E.Sym->getName(); 494 } 495 } 496 497 for (Export &E : Config->Exports) { 498 if (!E.ForwardTo.empty()) { 499 E.ExportName = undecorate(E.Name); 500 } else { 501 E.ExportName = undecorate(E.ExtName.empty() ? E.Name : E.ExtName); 502 } 503 } 504 505 // Uniquefy by name. 506 std::map<StringRef, Export *> Map; 507 std::vector<Export> V; 508 for (Export &E : Config->Exports) { 509 auto Pair = Map.insert(std::make_pair(E.ExportName, &E)); 510 bool Inserted = Pair.second; 511 if (Inserted) { 512 V.push_back(E); 513 continue; 514 } 515 Export *Existing = Pair.first->second; 516 if (E == *Existing || E.Name != Existing->Name) 517 continue; 518 llvm::errs() << "warning: duplicate /export option: " << E.Name << "\n"; 519 } 520 Config->Exports = std::move(V); 521 522 // Sort by name. 523 std::sort(Config->Exports.begin(), Config->Exports.end(), 524 [](const Export &A, const Export &B) { 525 return A.ExportName < B.ExportName; 526 }); 527 } 528 529 void assignExportOrdinals() { 530 // Assign unique ordinals if default (= 0). 531 uint16_t Max = 0; 532 for (Export &E : Config->Exports) 533 Max = std::max(Max, E.Ordinal); 534 for (Export &E : Config->Exports) 535 if (E.Ordinal == 0) 536 E.Ordinal = ++Max; 537 } 538 539 // Parses a string in the form of "key=value" and check 540 // if value matches previous values for the same key. 541 void checkFailIfMismatch(StringRef Arg) { 542 StringRef K, V; 543 std::tie(K, V) = Arg.split('='); 544 if (K.empty() || V.empty()) 545 fatal("/failifmismatch: invalid argument: " + Arg); 546 StringRef Existing = Config->MustMatch[K]; 547 if (!Existing.empty() && V != Existing) 548 fatal("/failifmismatch: mismatch detected: " + Existing + " and " + V + 549 " for key " + K); 550 Config->MustMatch[K] = V; 551 } 552 553 // Convert Windows resource files (.res files) to a .obj file 554 // using cvtres.exe. 555 std::unique_ptr<MemoryBuffer> 556 convertResToCOFF(const std::vector<MemoryBufferRef> &MBs) { 557 // Create an output file path. 558 SmallString<128> Path; 559 if (auto EC = llvm::sys::fs::createTemporaryFile("resource", "obj", Path)) 560 fatal(EC, "could not create temporary file"); 561 562 // Execute cvtres.exe. 563 Executor E("cvtres.exe"); 564 E.add("/machine:" + machineToStr(Config->Machine)); 565 E.add("/readonly"); 566 E.add("/nologo"); 567 E.add("/out:" + Path); 568 for (MemoryBufferRef MB : MBs) 569 E.add(MB.getBufferIdentifier()); 570 E.run(); 571 return check(MemoryBuffer::getFile(Path), "could not open " + Path); 572 } 573 574 // Create OptTable 575 576 // Create prefix string literals used in Options.td 577 #define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE; 578 #include "Options.inc" 579 #undef PREFIX 580 581 // Create table mapping all options defined in Options.td 582 static const llvm::opt::OptTable::Info infoTable[] = { 583 #define OPTION(X1, X2, ID, KIND, GROUP, ALIAS, X6, X7, X8, X9, X10) \ 584 { \ 585 X1, X2, X9, X10, OPT_##ID, llvm::opt::Option::KIND##Class, X8, X7, \ 586 OPT_##GROUP, OPT_##ALIAS, X6 \ 587 }, 588 #include "Options.inc" 589 #undef OPTION 590 }; 591 592 class COFFOptTable : public llvm::opt::OptTable { 593 public: 594 COFFOptTable() : OptTable(infoTable, true) {} 595 }; 596 597 // Parses a given list of options. 598 llvm::opt::InputArgList ArgParser::parse(ArrayRef<const char *> ArgsArr) { 599 // First, replace respnose files (@<file>-style options). 600 std::vector<const char *> Argv = replaceResponseFiles(ArgsArr); 601 602 // Make InputArgList from string vectors. 603 COFFOptTable Table; 604 unsigned MissingIndex; 605 unsigned MissingCount; 606 llvm::opt::InputArgList Args = 607 Table.ParseArgs(Argv, MissingIndex, MissingCount); 608 609 // Print the real command line if response files are expanded. 610 if (Args.hasArg(OPT_verbose) && ArgsArr.size() != Argv.size()) { 611 llvm::outs() << "Command line:"; 612 for (const char *S : Argv) 613 llvm::outs() << " " << S; 614 llvm::outs() << "\n"; 615 } 616 617 if (MissingCount) 618 fatal("missing arg value for \"" + Twine(Args.getArgString(MissingIndex)) + 619 "\", expected " + Twine(MissingCount) + 620 (MissingCount == 1 ? " argument." : " arguments.")); 621 for (auto *Arg : Args.filtered(OPT_UNKNOWN)) 622 llvm::errs() << "ignoring unknown argument: " << Arg->getSpelling() << "\n"; 623 return Args; 624 } 625 626 llvm::opt::InputArgList ArgParser::parseLINK(ArrayRef<const char *> Args) { 627 // Concatenate LINK env and given arguments and parse them. 628 Optional<std::string> Env = Process::GetEnv("LINK"); 629 if (!Env) 630 return parse(Args); 631 std::vector<const char *> V = tokenize(*Env); 632 V.insert(V.end(), Args.begin(), Args.end()); 633 return parse(V); 634 } 635 636 std::vector<const char *> ArgParser::tokenize(StringRef S) { 637 SmallVector<const char *, 16> Tokens; 638 StringSaver Saver(AllocAux); 639 llvm::cl::TokenizeWindowsCommandLine(S, Saver, Tokens); 640 return std::vector<const char *>(Tokens.begin(), Tokens.end()); 641 } 642 643 // Creates a new command line by replacing options starting with '@' 644 // character. '@<filename>' is replaced by the file's contents. 645 std::vector<const char *> 646 ArgParser::replaceResponseFiles(std::vector<const char *> Argv) { 647 SmallVector<const char *, 256> Tokens(Argv.data(), Argv.data() + Argv.size()); 648 StringSaver Saver(AllocAux); 649 ExpandResponseFiles(Saver, TokenizeWindowsCommandLine, Tokens); 650 return std::vector<const char *>(Tokens.begin(), Tokens.end()); 651 } 652 653 void printHelp(const char *Argv0) { 654 COFFOptTable Table; 655 Table.PrintHelp(llvm::outs(), Argv0, "LLVM Linker", false); 656 } 657 658 } // namespace coff 659 } // namespace lld 660