diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-11-27 13:33:15 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-11-27 13:33:15 +0000 |
commit | 5867690cfab812a22d0409a8b8cc996d30263d30 (patch) | |
tree | cdb8201569abb0f2e7ad1e0cd409fd5b0fa8c165 /llvm/lib/Object/MachOObject.cpp | |
parent | c983afc5a1a050ab204be564e4bddbe251fc5e19 (diff) | |
download | bcm5719-llvm-5867690cfab812a22d0409a8b8cc996d30263d30.tar.gz bcm5719-llvm-5867690cfab812a22d0409a8b8cc996d30263d30.zip |
macho-dump: Add support for dumping sections.
llvm-svn: 120215
Diffstat (limited to 'llvm/lib/Object/MachOObject.cpp')
-rw-r--r-- | llvm/lib/Object/MachOObject.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/llvm/lib/Object/MachOObject.cpp b/llvm/lib/Object/MachOObject.cpp index 236dfe0ce50..1e9ec70d422 100644 --- a/llvm/lib/Object/MachOObject.cpp +++ b/llvm/lib/Object/MachOObject.cpp @@ -243,3 +243,49 @@ MachOObject::ReadIndirectSymbolTableEntry(const macho::DysymtabLoadCommand &DLC, Index * sizeof(macho::IndirectSymbolTableEntry)); ReadInMemoryStruct(*this, Buffer->getBuffer(), Offset, Res); } + + +template<> +void SwapStruct(macho::Section &Value) { + SwapValue(Value.Address); + SwapValue(Value.Size); + SwapValue(Value.Offset); + SwapValue(Value.Align); + SwapValue(Value.RelocationTableOffset); + SwapValue(Value.NumRelocationTableEntries); + SwapValue(Value.Flags); + SwapValue(Value.Reserved1); + SwapValue(Value.Reserved2); +} +void MachOObject::ReadSection(const LoadCommandInfo &LCI, + unsigned Index, + InMemoryStruct<macho::Section> &Res) const { + assert(LCI.Command.Type == macho::LCT_Segment && + "Unexpected load command info!"); + uint64_t Offset = (LCI.Offset + sizeof(macho::SegmentLoadCommand) + + Index * sizeof(macho::Section)); + ReadInMemoryStruct(*this, Buffer->getBuffer(), Offset, Res); +} + +template<> +void SwapStruct(macho::Section64 &Value) { + SwapValue(Value.Address); + SwapValue(Value.Size); + SwapValue(Value.Offset); + SwapValue(Value.Align); + SwapValue(Value.RelocationTableOffset); + SwapValue(Value.NumRelocationTableEntries); + SwapValue(Value.Flags); + SwapValue(Value.Reserved1); + SwapValue(Value.Reserved2); + SwapValue(Value.Reserved3); +} +void MachOObject::ReadSection64(const LoadCommandInfo &LCI, + unsigned Index, + InMemoryStruct<macho::Section64> &Res) const { + assert(LCI.Command.Type == macho::LCT_Segment64 && + "Unexpected load command info!"); + uint64_t Offset = (LCI.Offset + sizeof(macho::Segment64LoadCommand) + + Index * sizeof(macho::Section64)); + ReadInMemoryStruct(*this, Buffer->getBuffer(), Offset, Res); +} |