aboutsummaryrefslogtreecommitdiffstats
path: root/tools/llvm-readobj/llvm-readobj.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/llvm-readobj/llvm-readobj.cpp')
-rw-r--r--tools/llvm-readobj/llvm-readobj.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/llvm-readobj/llvm-readobj.cpp b/tools/llvm-readobj/llvm-readobj.cpp
index f8f3086..32db723 100644
--- a/tools/llvm-readobj/llvm-readobj.cpp
+++ b/tools/llvm-readobj/llvm-readobj.cpp
@@ -25,6 +25,7 @@
#include "StreamWriter.h"
#include "llvm/Object/Archive.h"
#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/MachOUniversal.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
@@ -320,6 +321,19 @@ static void dumpArchive(const Archive *Arc) {
}
}
+/// @brief Dumps each object file in \a MachO Universal Binary;
+static void dumpMachOUniversalBinary(const MachOUniversalBinary *UBinary) {
+ for (const MachOUniversalBinary::ObjectForArch &Obj : UBinary->objects()) {
+ ErrorOr<std::unique_ptr<MachOObjectFile>> ObjOrErr = Obj.getAsObjectFile();
+ if (std::error_code EC = ObjOrErr.getError()) {
+ reportError(UBinary->getFileName(), EC.message());
+ continue;
+ }
+
+ if (MachOObjectFile *MachOObj = ObjOrErr.get().get())
+ dumpObject(MachOObj);
+ }
+}
/// @brief Opens \a File and dumps it.
static void dumpInput(StringRef File) {
@@ -339,6 +353,9 @@ static void dumpInput(StringRef File) {
if (Archive *Arc = dyn_cast<Archive>(&Binary))
dumpArchive(Arc);
+ else if (MachOUniversalBinary *UBinary =
+ dyn_cast<MachOUniversalBinary>(&Binary))
+ dumpMachOUniversalBinary(UBinary);
else if (ObjectFile *Obj = dyn_cast<ObjectFile>(&Binary))
dumpObject(Obj);
else