From fedb01603c66fe662ecab2c51e3fe4deb8544bf6 Mon Sep 17 00:00:00 2001 From: Alexander Shaposhnikov Date: Fri, 9 Feb 2018 23:33:31 +0000 Subject: [llvm-objcopy] Make modifications in-place if output is not specified If the output file is not specified make the modifications in-place (like binutils objcopy does). In particular, this fixes the behavior of Clang -gsplit-dwarf (if Clang is configured to use llvm-objcopy), previously it was creating .dwo files, but still leaving *dwo* sections in the original binary. Test plan: make check-all Differential revision: https://reviews.llvm.org/D42873 llvm-svn: 324783 --- llvm/tools/llvm-objcopy/llvm-objcopy.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'llvm/tools/llvm-objcopy') diff --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp index 8f5243cefa0..7d230390872 100644 --- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp +++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp @@ -72,8 +72,8 @@ LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, Error E) { } // end namespace llvm static cl::opt InputFilename(cl::Positional, cl::desc("")); -static cl::opt OutputFilename(cl::Positional, cl::desc(""), - cl::init("-")); +static cl::opt OutputFilename(cl::Positional, cl::desc("[ ]")); + static cl::opt OutputFormat("O", cl::desc("Set output format to one of the following:" "\n\tbinary")); @@ -340,7 +340,9 @@ int main(int argc, char **argv) { auto Reader = CreateReader(); auto Obj = Reader->create(); - auto Writer = CreateWriter(*Obj, OutputFilename); + StringRef Output = + OutputFilename.getNumOccurrences() ? OutputFilename : InputFilename; + auto Writer = CreateWriter(*Obj, Output); HandleArgs(*Obj, *Reader); Writer->finalize(); Writer->write(); -- cgit v1.2.3