[llvm] r178984 - Remove usage of InMemoryStruct in getSymbol.
Rafael Espindola
rafael.espindola at gmail.com
Sun Apr 7 08:35:18 PDT 2013
Author: rafael
Date: Sun Apr 7 10:35:18 2013
New Revision: 178984
URL: http://llvm.org/viewvc/llvm-project?rev=178984&view=rev
Log:
Remove usage of InMemoryStruct in getSymbol.
Modified:
llvm/trunk/include/llvm/Object/MachO.h
llvm/trunk/tools/llvm-readobj/MachODumper.cpp
Modified: llvm/trunk/include/llvm/Object/MachO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/MachO.h?rev=178984&r1=178983&r2=178984&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/MachO.h (original)
+++ llvm/trunk/include/llvm/Object/MachO.h Sun Apr 7 10:35:18 2013
@@ -156,6 +156,10 @@ public:
getLinkeditDataLoadCommand(LoadCommandInfo LCI) const;
const MachOFormat::Section64 *getSection64(DataRefImpl DRI) const;
const MachOFormat::Section *getSection(DataRefImpl DRI) const;
+ const MachOFormat::Symbol64TableEntry *
+ getSymbol64TableEntry(DataRefImpl DRI) const;
+ const MachOFormat::SymbolTableEntry *
+ getSymbolTableEntry(DataRefImpl DRI) const;
const MachOObject *getObject() const { return MachOObj.get(); }
@@ -225,16 +229,10 @@ private:
void moveToNextSection(DataRefImpl &DRI) const;
const MachOFormat::SymbolTableEntry *
- getSymbolTableEntry(DataRefImpl DRI) const;
-
- const MachOFormat::SymbolTableEntry *
getSymbolTableEntry(DataRefImpl DRI,
const MachOFormat::SymtabLoadCommand *SymtabLoadCmd) const;
const MachOFormat::Symbol64TableEntry *
- getSymbol64TableEntry(DataRefImpl DRI) const;
-
- const MachOFormat::Symbol64TableEntry *
getSymbol64TableEntry(DataRefImpl DRI,
const MachOFormat::SymtabLoadCommand *SymtabLoadCmd) const;
Modified: llvm/trunk/tools/llvm-readobj/MachODumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/MachODumper.cpp?rev=178984&r1=178983&r2=178984&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/MachODumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/MachODumper.cpp Sun Apr 7 10:35:18 2013
@@ -197,38 +197,20 @@ static void getSection(const MachOObject
}
}
-static void getSymbolTableEntry(const MachOObject *MachO,
- DataRefImpl DRI,
- InMemoryStruct<macho::SymbolTableEntry> &Res) {
- InMemoryStruct<macho::SymtabLoadCommand> SymtabLoadCmd;
- LoadCommandInfo LCI = MachO->getLoadCommandInfo(DRI.d.a);
- MachO->ReadSymtabLoadCommand(LCI, SymtabLoadCmd);
- MachO->ReadSymbolTableEntry(SymtabLoadCmd->SymbolTableOffset, DRI.d.b, Res);
-}
-
-static void getSymbol64TableEntry(const MachOObject *MachO,
- DataRefImpl DRI,
- InMemoryStruct<macho::Symbol64TableEntry> &Res) {
- InMemoryStruct<macho::SymtabLoadCommand> SymtabLoadCmd;
- LoadCommandInfo LCI = MachO->getLoadCommandInfo(DRI.d.a);
- MachO->ReadSymtabLoadCommand(LCI, SymtabLoadCmd);
- MachO->ReadSymbol64TableEntry(SymtabLoadCmd->SymbolTableOffset, DRI.d.b, Res);
-}
-
-static void getSymbol(const MachOObject *MachOObj,
+static void getSymbol(const MachOObjectFile *Obj,
DataRefImpl DRI,
MachOSymbol &Symbol) {
+ const MachOObject *MachOObj = Obj->getObject();
if (MachOObj->is64Bit()) {
- InMemoryStruct<macho::Symbol64TableEntry> Entry;
- getSymbol64TableEntry(MachOObj, DRI, Entry);
+ const MachOFormat::Symbol64TableEntry *Entry =
+ Obj->getSymbol64TableEntry( DRI);
Symbol.StringIndex = Entry->StringIndex;
Symbol.Type = Entry->Type;
Symbol.SectionIndex = Entry->SectionIndex;
Symbol.Flags = Entry->Flags;
Symbol.Value = Entry->Value;
} else {
- InMemoryStruct<macho::SymbolTableEntry> Entry;
- getSymbolTableEntry(MachOObj, DRI, Entry);
+ const MachOFormat::SymbolTableEntry *Entry = Obj->getSymbolTableEntry(DRI);
Symbol.StringIndex = Entry->StringIndex;
Symbol.Type = Entry->Type;
Symbol.SectionIndex = Entry->SectionIndex;
@@ -397,10 +379,8 @@ void MachODumper::printSymbol(symbol_ite
if (SymI->getName(SymbolName))
SymbolName = "";
- const MachOObject *MachO = const_cast<MachOObjectFile*>(Obj)->getObject();
-
MachOSymbol Symbol;
- getSymbol(MachO, SymI->getRawDataRefImpl(), Symbol);
+ getSymbol(Obj, SymI->getRawDataRefImpl(), Symbol);
StringRef SectionName;
section_iterator SecI(Obj->end_sections());
More information about the llvm-commits
mailing list