Index: ELF/Config.h =================================================================== --- ELF/Config.h +++ ELF/Config.h @@ -89,12 +89,12 @@ llvm::StringRef MapFile; llvm::StringRef OutputFile; llvm::StringRef OptRemarksFilename; + llvm::StringRef ProgName; llvm::StringRef SoName; llvm::StringRef Sysroot; llvm::StringRef ThinLTOCacheDir; std::string Rpath; std::vector VersionDefinitions; - std::vector Argv; std::vector AuxiliaryList; std::vector FilterList; std::vector SearchPaths; Index: ELF/Driver.h =================================================================== --- ELF/Driver.h +++ ELF/Driver.h @@ -63,7 +63,7 @@ #undef OPTION }; -void printHelp(const char *Argv0); +void printHelp(); std::string createResponseFile(const llvm::opt::InputArgList &Args); llvm::Optional findFromSearchPaths(StringRef Path); Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ ELF/Driver.cpp @@ -71,12 +71,6 @@ bool elf::link(ArrayRef Args, bool CanExitEarly, raw_ostream &Error) { - errorHandler().LogName = Args[0]; - errorHandler().ErrorLimitExceededMsg = - "too many errors emitted, stopping now (use " - "-error-limit=0 to see all errors)"; - errorHandler().ErrorOS = &Error; - errorHandler().ColorDiagnostics = Error.has_colors(); InputSections.clear(); OutputSections.clear(); Tar = nullptr; @@ -89,8 +83,14 @@ Driver = make(); Script = make(); Symtab = make(); - Config->Argv = {Args.begin(), Args.end()}; + Config->ProgName = Args[0]; + errorHandler().LogName = Config->ProgName; + errorHandler().ErrorLimitExceededMsg = + "too many errors emitted, stopping now (use " + "-error-limit=0 to see all errors)"; + errorHandler().ErrorOS = &Error; + errorHandler().ColorDiagnostics = Error.has_colors(); Driver->main(Args, CanExitEarly); // Exit immediately if we don't need to return to the caller. @@ -317,7 +317,7 @@ // Handle -help if (Args.hasArg(OPT_help)) { - printHelp(ArgsArr[0]); + printHelp(); return; } @@ -690,7 +690,7 @@ Config->ZWxneeded = hasZOption(Args, "wxneeded"); // Parse LTO plugin-related options for compatibility with gold. - std::vector LTOOptions({Config->Argv[0].data()}); + std::vector LTOOptions({Config->ProgName.data()}); for (auto *Arg : Args.filtered(OPT_plugin_opt)) { StringRef S = Arg->getValue(); if (S == "disable-verify") Index: ELF/DriverUtils.cpp =================================================================== --- ELF/DriverUtils.cpp +++ ELF/DriverUtils.cpp @@ -114,9 +114,9 @@ return Args; } -void elf::printHelp(const char *Argv0) { - ELFOptTable().PrintHelp(outs(), Argv0, "lld", false /*ShowHidden*/, - true /*ShowAllAliases*/); +void elf::printHelp() { + ELFOptTable().PrintHelp(outs(), Config->ProgName.data(), "lld", + false /*ShowHidden*/, true /*ShowAllAliases*/); outs() << "\n"; // Scripts generated by Libtool versions up to at least 2.4.6 (the most @@ -125,7 +125,7 @@ // assume that the linker doesn't support very basic features such as // shared libraries. Therefore, we need to print out at least "elf". // Here, we print out all the targets that we support. - outs() << Argv0 << ": supported targets: " + outs() << Config->ProgName << ": supported targets: " << "elf32-i386 elf32-iamcu elf32-littlearm elf32-ntradbigmips " << "elf32-ntradlittlemips elf32-powerpc elf32-tradbigmips " << "elf32-tradlittlemips elf32-x86-64 "