[PATCH] D42873: [llvm-objcopy] Adjust --strip-dwo behavior

Alexander Shaposhnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 2 15:30:25 PST 2018


alexshap created this revision.
alexshap added reviewers: jakehehrlich, jhenderson.
Herald added subscribers: JDevlieghere, aprantl.

If the output file is not specified make the modifications in-place (like binutils objcopy does).
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 those sections in the original binary.


Repository:
  rL LLVM

https://reviews.llvm.org/D42873

Files:
  tools/llvm-objcopy/llvm-objcopy.cpp


Index: tools/llvm-objcopy/llvm-objcopy.cpp
===================================================================
--- tools/llvm-objcopy/llvm-objcopy.cpp
+++ tools/llvm-objcopy/llvm-objcopy.cpp
@@ -340,7 +340,10 @@
 
   auto Reader = CreateReader();
   auto Obj = Reader->create();
-  auto Writer = CreateWriter(*Obj, OutputFilename);
+  StringRef Output = OutputFilename;
+  if (StripDWO && !OutputFilename.getNumOccurrences())
+    Output = InputFilename;
+  auto Writer = CreateWriter(*Obj, Output);
   HandleArgs(*Obj, *Reader);
   Writer->finalize();
   Writer->write();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42873.132696.patch
Type: text/x-patch
Size: 573 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180202/118a0908/attachment.bin>


More information about the llvm-commits mailing list