From b7b11f7bac5c136d0b5b0e333dde9e634730a936 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Sun, 7 Apr 2013 14:40:18 +0000 Subject: [PATCH] Remove last use of InMemoryStruct in llvm-objdump. llvm-svn: 178979 --- llvm/include/llvm/Object/MachO.h | 10 ++++++++++ llvm/lib/Object/MachOObjectFile.cpp | 8 ++++++++ llvm/tools/llvm-objdump/MachODump.cpp | 4 ++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/Object/MachO.h b/llvm/include/llvm/Object/MachO.h index 8543ecc8291c..f026e6c69d49 100644 --- a/llvm/include/llvm/Object/MachO.h +++ b/llvm/include/llvm/Object/MachO.h @@ -113,6 +113,13 @@ namespace MachOFormat { support::ulittle32_t NumSections; support::ulittle32_t Flags; }; + + struct LinkeditDataLoadCommand { + support::ulittle32_t Type; + support::ulittle32_t Size; + support::ulittle32_t DataOffset; + support::ulittle32_t DataSize; + }; } typedef MachOObject::LoadCommandInfo LoadCommandInfo; @@ -145,6 +152,9 @@ public: ArrayRef getSectionRawName(DataRefImpl Sec) const; ArrayRefgetSectionRawFinalSegmentName(DataRefImpl Sec) const; + const MachOFormat::LinkeditDataLoadCommand * + getLinkeditDataLoadCommand(LoadCommandInfo LCI) const; + MachOObject *getObject() { return MachOObj.get(); } static inline bool classof(const Binary *v) { diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index 1eb14f31ff43..94827693e998 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -75,6 +75,14 @@ MachOObjectFile::getSegmentLoadCommand(LoadCommandInfo LCI) const { return reinterpret_cast(Data.data()); } +const MachOFormat::LinkeditDataLoadCommand * +MachOObjectFile::getLinkeditDataLoadCommand(LoadCommandInfo LCI) const { + StringRef Data = MachOObj->getData(LCI.Offset, + sizeof(MachOFormat::LinkeditDataLoadCommand)); + return + reinterpret_cast(Data.data()); +} + const MachOFormat::Segment64LoadCommand * MachOObjectFile::getSegment64LoadCommand(LoadCommandInfo LCI) const { StringRef Data = MachOObj->getData(LCI.Offset, diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp index b122cd3b7abf..894e769115cc 100644 --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -223,8 +223,8 @@ static void getSectionsAndSymbols(const macho::Header &Header, if (LCI.Command.Type == macho::LCT_FunctionStarts) { // We found a function starts segment, parse the addresses for later // consumption. - InMemoryStruct LLC; - MachOObj->getObject()->ReadLinkeditDataLoadCommand(LCI, LLC); + const MachOFormat::LinkeditDataLoadCommand *LLC = + MachOObj->getLinkeditDataLoadCommand(LCI); MachOObj->getObject()->ReadULEB128s(LLC->DataOffset, FoundFns); }