[llvm-commits] [llvm] r138807 - in /llvm/trunk: include/llvm/Object/MachOFormat.h include/llvm/Object/MachOObject.h lib/Object/MachOObject.cpp tools/macho-dump/macho-dump.cpp

Benjamin Kramer benny.kra at googlemail.com
Tue Aug 30 11:33:37 PDT 2011


Author: d0k
Date: Tue Aug 30 13:33:37 2011
New Revision: 138807

URL: http://llvm.org/viewvc/llvm-project?rev=138807&view=rev
Log:
Teach macho-dump how to dump linkedit_data load commands.

Modified:
    llvm/trunk/include/llvm/Object/MachOFormat.h
    llvm/trunk/include/llvm/Object/MachOObject.h
    llvm/trunk/lib/Object/MachOObject.cpp
    llvm/trunk/tools/macho-dump/macho-dump.cpp

Modified: llvm/trunk/include/llvm/Object/MachOFormat.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/MachOFormat.h?rev=138807&r1=138806&r2=138807&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/MachOFormat.h (original)
+++ llvm/trunk/include/llvm/Object/MachOFormat.h Tue Aug 30 13:33:37 2011
@@ -137,7 +137,10 @@
     LCT_Symtab = 0x2,
     LCT_Dysymtab = 0xb,
     LCT_Segment64 = 0x19,
-    LCT_UUID = 0x1b
+    LCT_UUID = 0x1b,
+    LCT_CodeSignature = 0x1d,
+    LCT_SegmentSplitInfo = 0x1e,
+    LCT_FunctionStarts = 0x26
   };
 
   /// \brief Load command structure.
@@ -218,6 +221,13 @@
     uint32_t NumLocalRelocationTableEntries;
   };
 
+  struct LinkeditDataLoadCommand {
+    uint32_t Type;
+    uint32_t Size;
+    uint32_t DataOffset;
+    uint32_t DataSize;
+  };
+
   /// @}
   /// @name Section Data
   /// @{

Modified: llvm/trunk/include/llvm/Object/MachOObject.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/MachOObject.h?rev=138807&r1=138806&r2=138807&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/MachOObject.h (original)
+++ llvm/trunk/include/llvm/Object/MachOObject.h Tue Aug 30 13:33:37 2011
@@ -150,6 +150,9 @@
   void ReadDysymtabLoadCommand(
     const LoadCommandInfo &LCI,
     InMemoryStruct<macho::DysymtabLoadCommand> &Res) const;
+  void ReadLinkeditDataLoadCommand(
+    const LoadCommandInfo &LCI,
+    InMemoryStruct<macho::LinkeditDataLoadCommand> &Res) const;
   void ReadIndirectSymbolTableEntry(
     const macho::DysymtabLoadCommand &DLC,
     unsigned Index,

Modified: llvm/trunk/lib/Object/MachOObject.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObject.cpp?rev=138807&r1=138806&r2=138807&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObject.cpp (original)
+++ llvm/trunk/lib/Object/MachOObject.cpp Tue Aug 30 13:33:37 2011
@@ -244,6 +244,18 @@
 }
 
 template<>
+void SwapStruct(macho::LinkeditDataLoadCommand &Value) {
+  SwapValue(Value.Type);
+  SwapValue(Value.Size);
+  SwapValue(Value.DataOffset);
+  SwapValue(Value.DataSize);
+}
+void MachOObject::ReadLinkeditDataLoadCommand(const LoadCommandInfo &LCI,
+                    InMemoryStruct<macho::LinkeditDataLoadCommand> &Res) const {
+  ReadInMemoryStruct(*this, Buffer->getBuffer(), LCI.Offset, Res);
+}
+
+template<>
 void SwapStruct(macho::IndirectSymbolTableEntry &Value) {
   SwapValue(Value.Index);
 }

Modified: llvm/trunk/tools/macho-dump/macho-dump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/macho-dump/macho-dump.cpp?rev=138807&r1=138806&r2=138807&view=diff
==============================================================================
--- llvm/trunk/tools/macho-dump/macho-dump.cpp (original)
+++ llvm/trunk/tools/macho-dump/macho-dump.cpp Tue Aug 30 13:33:37 2011
@@ -310,6 +310,20 @@
   return Res;
 }
 
+static int DumpLinkeditDataCommand(MachOObject &Obj,
+                                   const MachOObject::LoadCommandInfo &LCI) {
+  InMemoryStruct<macho::LinkeditDataLoadCommand> LLC;
+  Obj.ReadLinkeditDataLoadCommand(LCI, LLC);
+  if (!LLC)
+    return Error("unable to read segment load command");
+
+  outs() << "  ('dataoff', " << LLC->DataOffset << ")\n"
+         << "  ('datasize', " << LLC->DataSize << ")\n";
+
+  return 0;
+}
+
+
 static int DumpLoadCommand(MachOObject &Obj, unsigned Index) {
   const MachOObject::LoadCommandInfo &LCI = Obj.getLoadCommandInfo(Index);
   int Res = 0;
@@ -330,6 +344,11 @@
   case macho::LCT_Dysymtab:
     Res = DumpDysymtabCommand(Obj, LCI);
     break;
+  case macho::LCT_CodeSignature:
+  case macho::LCT_SegmentSplitInfo:
+  case macho::LCT_FunctionStarts:
+    Res = DumpLinkeditDataCommand(Obj, LCI);
+    break;
   default:
     Warning("unknown load command: " + Twine(LCI.Command.Type));
     break;





More information about the llvm-commits mailing list