diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h index cedc27c410b6..4253399a3235 100644 --- a/lld/ELF/Config.h +++ b/lld/ELF/Config.h @@ -89,12 +89,12 @@ struct Configuration { 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; diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 94b42407bf49..7e55cd42536b 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -89,7 +89,7 @@ bool elf::link(ArrayRef Args, bool CanExitEarly, Driver = make(); Script = make(); Symtab = make(); - Config->Argv = {Args.begin(), Args.end()}; + Config->ProgName = Args[0]; Driver->main(Args, CanExitEarly); @@ -317,7 +317,7 @@ void LinkerDriver::main(ArrayRef ArgsArr, bool CanExitEarly) { // Handle -help if (Args.hasArg(OPT_help)) { - printHelp(ArgsArr[0]); + printHelp(); return; } @@ -690,7 +690,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) { 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") diff --git a/lld/ELF/Driver.h b/lld/ELF/Driver.h index 351d7926de71..09165a943c8c 100644 --- a/lld/ELF/Driver.h +++ b/lld/ELF/Driver.h @@ -63,7 +63,7 @@ enum { #undef OPTION }; -void printHelp(const char *Argv0); +void printHelp(); std::string createResponseFile(const llvm::opt::InputArgList &Args); llvm::Optional findFromSearchPaths(StringRef Path); diff --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp index 7ad92fe1468f..66b06089720a 100644 --- a/lld/ELF/DriverUtils.cpp +++ b/lld/ELF/DriverUtils.cpp @@ -114,9 +114,9 @@ opt::InputArgList ELFOptTable::parse(ArrayRef Argv) { 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 @@ void elf::printHelp(const char *Argv0) { // 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 "