Finish templating MachObjectFile over endianness.

We are now able to handle big endian macho files in llvm-readobject. Thanks to
David Fang for providing the object files.

llvm-svn: 179440
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 4790d7a..5a0519d 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -191,6 +191,14 @@
   return a_addr < b_addr;
 }
 
+StringRef
+getSectionFinalSegmentName(const MachOObjectFileBase *MachO, DataRefImpl DR) {
+  if (const MachOObjectFileLE *O = dyn_cast<MachOObjectFileLE>(MachO))
+    return O->getSectionFinalSegmentName(DR);
+  const MachOObjectFileBE *O = dyn_cast<MachOObjectFileBE>(MachO);
+  return O->getSectionFinalSegmentName(DR);
+}
+
 static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
   const Target *TheTarget = getTarget(Obj);
   // getTarget() will have already issued a diagnostic if necessary, so
@@ -255,9 +263,10 @@
     std::sort(Rels.begin(), Rels.end(), RelocAddressLess);
 
     StringRef SegmentName = "";
-    if (const MachOObjectFileBase *MachO = dyn_cast<const MachOObjectFileBase>(Obj)) {
+    if (const MachOObjectFileBase *MachO =
+        dyn_cast<const MachOObjectFileBase>(Obj)) {
       DataRefImpl DR = i->getRawDataRefImpl();
-      SegmentName = MachO->getSectionFinalSegmentName(DR);
+      SegmentName = getSectionFinalSegmentName(MachO, DR);
     }
     StringRef name;
     if (error(i->getName(name))) break;
@@ -591,9 +600,10 @@
       else if (Section == o->end_sections())
         outs() << "*UND*";
       else {
-        if (const MachOObjectFileBase *MachO = dyn_cast<const MachOObjectFileBase>(o)) {
+        if (const MachOObjectFileBase *MachO =
+            dyn_cast<const MachOObjectFileBase>(o)) {
           DataRefImpl DR = Section->getRawDataRefImpl();
-          StringRef SegmentName = MachO->getSectionFinalSegmentName(DR);
+          StringRef SegmentName = getSectionFinalSegmentName(MachO, DR);
           outs() << SegmentName << ",";
         }
         StringRef SectionName;