From 68d287d19e6918f46e58456fdd237c049efe372e Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Sat, 6 Apr 2013 03:50:05 +0000 Subject: Remove last use of InMemoryStruct from MachOObjectFile.cpp. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178948 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Object/MachOObjectFile.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'lib/Object/MachOObjectFile.cpp') diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp index e2b0468b9a..1eb14f31ff 100644 --- a/lib/Object/MachOObjectFile.cpp +++ b/lib/Object/MachOObjectFile.cpp @@ -68,6 +68,21 @@ MachOObjectFile::getSymtabLoadCommand(LoadCommandInfo LCI) const { return reinterpret_cast(Data.data()); } +const MachOFormat::SegmentLoadCommand * +MachOObjectFile::getSegmentLoadCommand(LoadCommandInfo LCI) const { + StringRef Data = MachOObj->getData(LCI.Offset, + sizeof(MachOFormat::SegmentLoadCommand)); + return reinterpret_cast(Data.data()); +} + +const MachOFormat::Segment64LoadCommand * +MachOObjectFile::getSegment64LoadCommand(LoadCommandInfo LCI) const { + StringRef Data = MachOObj->getData(LCI.Offset, + sizeof(MachOFormat::Segment64LoadCommand)); + return + reinterpret_cast(Data.data()); +} + void MachOObjectFile::moveToNextSymbol(DataRefImpl &DRI) const { uint32_t LoadCommandCount = MachOObj->getHeader().NumLoadCommands; while (DRI.d.a < LoadCommandCount) { @@ -436,13 +451,13 @@ void MachOObjectFile::moveToNextSection(DataRefImpl &DRI) const { while (DRI.d.a < LoadCommandCount) { LoadCommandInfo LCI = MachOObj->getLoadCommandInfo(DRI.d.a); if (LCI.Command.Type == macho::LCT_Segment) { - InMemoryStruct SegmentLoadCmd; - MachOObj->ReadSegmentLoadCommand(LCI, SegmentLoadCmd); + const MachOFormat::SegmentLoadCommand *SegmentLoadCmd = + getSegmentLoadCommand(LCI); if (DRI.d.b < SegmentLoadCmd->NumSections) return; } else if (LCI.Command.Type == macho::LCT_Segment64) { - InMemoryStruct Segment64LoadCmd; - MachOObj->ReadSegment64LoadCommand(LCI, Segment64LoadCmd); + const MachOFormat::Segment64LoadCommand *Segment64LoadCmd = + getSegment64LoadCommand(LCI); if (DRI.d.b < Segment64LoadCmd->NumSections) return; } -- cgit v1.2.3-18-g5258