[PATCH] D51758: [Xray] tooling allow MachO format support

David CARLIER via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 6 15:53:25 PDT 2018


devnexen created this revision.
devnexen added a reviewer: dberris.
devnexen created this object with visibility "All Users".
Herald added a subscriber: llvm-commits.

- Getting writable xray __DATA sections from MachO as well.


Repository:
  rL LLVM

https://reviews.llvm.org/D51758

Files:
  lib/XRay/InstrumentationMap.cpp


Index: lib/XRay/InstrumentationMap.cpp
===================================================================
--- lib/XRay/InstrumentationMap.cpp
+++ lib/XRay/InstrumentationMap.cpp
@@ -47,18 +47,18 @@
 }
 
 static Error
-loadELF64(StringRef Filename, object::OwningBinary<object::ObjectFile> &ObjFile,
+loadObj(StringRef Filename, object::OwningBinary<object::ObjectFile> &ObjFile,
           InstrumentationMap::SledContainer &Sleds,
           InstrumentationMap::FunctionAddressMap &FunctionAddresses,
           InstrumentationMap::FunctionAddressReverseMap &FunctionIds) {
   InstrumentationMap Map;
 
   // Find the section named "xray_instr_map".
-  if (!ObjFile.getBinary()->isELF() ||
+  if ((!ObjFile.getBinary()->isELF() && !ObjFile.getBinary()->isMachO()) ||
       !(ObjFile.getBinary()->getArch() == Triple::x86_64 ||
         ObjFile.getBinary()->getArch() == Triple::ppc64le))
     return make_error<StringError>(
-        "File format not supported (only does ELF little endian 64-bit).",
+        "File format not supported..",
         std::make_error_code(std::errc::not_supported));
 
   StringRef Contents = "";
@@ -191,7 +191,7 @@
     if (auto E = loadYAML(Fd, FileSize, Filename, Map.Sleds,
                           Map.FunctionAddresses, Map.FunctionIds))
       return std::move(E);
-  } else if (auto E = loadELF64(Filename, *ObjectFileOrError, Map.Sleds,
+  } else if (auto E = loadObj(Filename, *ObjectFileOrError, Map.Sleds,
                                 Map.FunctionAddresses, Map.FunctionIds)) {
     return std::move(E);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51758.164302.patch
Type: text/x-patch
Size: 1563 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180906/8a48b08d/attachment.bin>


More information about the llvm-commits mailing list