diff options
author | Michael Pozulp <pozulp.llvm@gmail.com> | 2019-09-14 01:14:43 +0000 |
---|---|---|
committer | Michael Pozulp <pozulp.llvm@gmail.com> | 2019-09-14 01:14:43 +0000 |
commit | c45fd0cad428f531c30f0629852aab2fcebe7b47 (patch) | |
tree | 41a27308ad46236caf46d6af44520bf717190544 /llvm/tools/llvm-objcopy/llvm-objcopy.cpp | |
parent | 4f3a4a8ca2f141bc32070c84b9bd29a5e2a66aa4 (diff) | |
download | llvm-c45fd0cad428f531c30f0629852aab2fcebe7b47.zip llvm-c45fd0cad428f531c30f0629852aab2fcebe7b47.tar.gz llvm-c45fd0cad428f531c30f0629852aab2fcebe7b47.tar.bz2 |
[llvm-objcopy] Add support for response files in llvm-strip and llvm-objcopy
Summary: Addresses https://bugs.llvm.org/show_bug.cgi?id=42671
Reviewers: jhenderson, espindola, alexshap, rupprecht
Reviewed By: jhenderson
Subscribers: seiya, emaste, arichardson, jakehehrlich, MaskRay, abrachet, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D65372
llvm-svn: 371911
Diffstat (limited to 'llvm/tools/llvm-objcopy/llvm-objcopy.cpp')
-rw-r--r-- | llvm/tools/llvm-objcopy/llvm-objcopy.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp index 9c0145f..e9094f2 100644 --- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp +++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp @@ -29,6 +29,7 @@ #include "llvm/Option/ArgList.h" #include "llvm/Option/Option.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorOr.h" @@ -36,6 +37,7 @@ #include "llvm/Support/Memory.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" +#include "llvm/Support/StringSaver.h" #include "llvm/Support/WithColor.h" #include "llvm/Support/raw_ostream.h" #include <algorithm> @@ -310,9 +312,25 @@ int main(int argc, char **argv) { InitLLVM X(argc, argv); ToolName = argv[0]; bool IsStrip = sys::path::stem(ToolName).contains("strip"); + + // Expand response files. + // TODO: Move these lines, which are copied from lib/Support/CommandLine.cpp, + // into a separate function in the CommandLine library and call that function + // here. This is duplicated code. + SmallVector<const char *, 20> NewArgv(argv, argv + argc); + BumpPtrAllocator A; + StringSaver Saver(A); + cl::ExpandResponseFiles(Saver, + Triple(sys::getProcessTriple()).isOSWindows() + ? cl::TokenizeWindowsCommandLine + : cl::TokenizeGNUCommandLine, + NewArgv); + + auto Args = makeArrayRef(NewArgv).drop_front(); + Expected<DriverConfig> DriverConfig = - IsStrip ? parseStripOptions(makeArrayRef(argv + 1, argc), reportWarning) - : parseObjcopyOptions(makeArrayRef(argv + 1, argc)); + IsStrip ? parseStripOptions(Args, reportWarning) + : parseObjcopyOptions(Args); if (!DriverConfig) { logAllUnhandledErrors(DriverConfig.takeError(), WithColor::error(errs(), ToolName)); |