llvm.org GIT mirror llvm / 1efa604
Remove usage of InMemoryStruct in getSymbol. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178984 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 7 years ago
2 changed file(s) with 10 addition(s) and 32 deletion(s). Raw diff Collapse all Expand all
155155 getLinkeditDataLoadCommand(LoadCommandInfo LCI) const;
156156 const MachOFormat::Section64 *getSection64(DataRefImpl DRI) const;
157157 const MachOFormat::Section *getSection(DataRefImpl DRI) const;
158 const MachOFormat::Symbol64TableEntry *
159 getSymbol64TableEntry(DataRefImpl DRI) const;
160 const MachOFormat::SymbolTableEntry *
161 getSymbolTableEntry(DataRefImpl DRI) const;
158162
159163 const MachOObject *getObject() const { return MachOObj.get(); }
160164
224228 void moveToNextSection(DataRefImpl &DRI) const;
225229
226230 const MachOFormat::SymbolTableEntry *
227 getSymbolTableEntry(DataRefImpl DRI) const;
228
229 const MachOFormat::SymbolTableEntry *
230231 getSymbolTableEntry(DataRefImpl DRI,
231232 const MachOFormat::SymtabLoadCommand *SymtabLoadCmd) const;
232
233 const MachOFormat::Symbol64TableEntry *
234 getSymbol64TableEntry(DataRefImpl DRI) const;
235233
236234 const MachOFormat::Symbol64TableEntry *
237235 getSymbol64TableEntry(DataRefImpl DRI,
196196 }
197197 }
198198
199 static void getSymbolTableEntry(const MachOObject *MachO,
200 DataRefImpl DRI,
201 InMemoryStruct &Res) {
202 InMemoryStruct SymtabLoadCmd;
203 LoadCommandInfo LCI = MachO->getLoadCommandInfo(DRI.d.a);
204 MachO->ReadSymtabLoadCommand(LCI, SymtabLoadCmd);
205 MachO->ReadSymbolTableEntry(SymtabLoadCmd->SymbolTableOffset, DRI.d.b, Res);
206 }
207
208 static void getSymbol64TableEntry(const MachOObject *MachO,
209 DataRefImpl DRI,
210 InMemoryStruct &Res) {
211 InMemoryStruct SymtabLoadCmd;
212 LoadCommandInfo LCI = MachO->getLoadCommandInfo(DRI.d.a);
213 MachO->ReadSymtabLoadCommand(LCI, SymtabLoadCmd);
214 MachO->ReadSymbol64TableEntry(SymtabLoadCmd->SymbolTableOffset, DRI.d.b, Res);
215 }
216
217 static void getSymbol(const MachOObject *MachOObj,
199 static void getSymbol(const MachOObjectFile *Obj,
218200 DataRefImpl DRI,
219201 MachOSymbol &Symbol) {
202 const MachOObject *MachOObj = Obj->getObject();
220203 if (MachOObj->is64Bit()) {
221 InMemoryStruct Entry;
222 getSymbol64TableEntry(MachOObj, DRI, Entry);
204 const MachOFormat::Symbol64TableEntry *Entry =
205 Obj->getSymbol64TableEntry( DRI);
223206 Symbol.StringIndex = Entry->StringIndex;
224207 Symbol.Type = Entry->Type;
225208 Symbol.SectionIndex = Entry->SectionIndex;
226209 Symbol.Flags = Entry->Flags;
227210 Symbol.Value = Entry->Value;
228211 } else {
229 InMemoryStruct Entry;
230 getSymbolTableEntry(MachOObj, DRI, Entry);
212 const MachOFormat::SymbolTableEntry *Entry = Obj->getSymbolTableEntry(DRI);
231213 Symbol.StringIndex = Entry->StringIndex;
232214 Symbol.Type = Entry->Type;
233215 Symbol.SectionIndex = Entry->SectionIndex;
396378 if (SymI->getName(SymbolName))
397379 SymbolName = "";
398380
399 const MachOObject *MachO = const_cast(Obj)->getObject();
400
401381 MachOSymbol Symbol;
402 getSymbol(MachO, SymI->getRawDataRefImpl(), Symbol);
382 getSymbol(Obj, SymI->getRawDataRefImpl(), Symbol);
403383
404384 StringRef SectionName;
405385 section_iterator SecI(Obj->end_sections());