forked from OSchip/llvm-project
parent
79bb550577
commit
31fce89645
|
@ -160,6 +160,7 @@ public:
|
||||||
getSymbol64TableEntry(DataRefImpl DRI) const;
|
getSymbol64TableEntry(DataRefImpl DRI) const;
|
||||||
const MachOFormat::SymbolTableEntry *
|
const MachOFormat::SymbolTableEntry *
|
||||||
getSymbolTableEntry(DataRefImpl DRI) const;
|
getSymbolTableEntry(DataRefImpl DRI) const;
|
||||||
|
bool is64Bit() const;
|
||||||
|
|
||||||
const MachOObject *getObject() const { return MachOObj.get(); }
|
const MachOObject *getObject() const { return MachOObj.get(); }
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,9 @@ MachOObjectFile::MachOObjectFile(MemoryBuffer *Object, MachOObject *MOO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MachOObjectFile::is64Bit() const {
|
||||||
|
return MachOObj->is64Bit();
|
||||||
|
}
|
||||||
|
|
||||||
ObjectFile *ObjectFile::createMachOObjectFile(MemoryBuffer *Buffer) {
|
ObjectFile *ObjectFile::createMachOObjectFile(MemoryBuffer *Buffer) {
|
||||||
error_code ec;
|
error_code ec;
|
||||||
|
|
|
@ -157,20 +157,10 @@ namespace {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is64BitLoadCommand(const MachOObject *MachOObj, DataRefImpl DRI) {
|
|
||||||
LoadCommandInfo LCI = MachOObj->getLoadCommandInfo(DRI.d.a);
|
|
||||||
if (LCI.Command.Type == macho::LCT_Segment64)
|
|
||||||
return true;
|
|
||||||
assert(LCI.Command.Type == macho::LCT_Segment && "Unexpected Type.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void getSection(const MachOObjectFile *Obj,
|
static void getSection(const MachOObjectFile *Obj,
|
||||||
DataRefImpl DRI,
|
DataRefImpl DRI,
|
||||||
MachOSection &Section) {
|
MachOSection &Section) {
|
||||||
const MachOObject *MachOObj = Obj->getObject();
|
if (Obj->is64Bit()) {
|
||||||
|
|
||||||
if (is64BitLoadCommand(MachOObj, DRI)) {
|
|
||||||
const MachOFormat::Section64 *Sect = Obj->getSection64(DRI);
|
const MachOFormat::Section64 *Sect = Obj->getSection64(DRI);
|
||||||
|
|
||||||
Section.Address = Sect->Address;
|
Section.Address = Sect->Address;
|
||||||
|
@ -200,8 +190,7 @@ static void getSection(const MachOObjectFile *Obj,
|
||||||
static void getSymbol(const MachOObjectFile *Obj,
|
static void getSymbol(const MachOObjectFile *Obj,
|
||||||
DataRefImpl DRI,
|
DataRefImpl DRI,
|
||||||
MachOSymbol &Symbol) {
|
MachOSymbol &Symbol) {
|
||||||
const MachOObject *MachOObj = Obj->getObject();
|
if (Obj->is64Bit()) {
|
||||||
if (MachOObj->is64Bit()) {
|
|
||||||
const MachOFormat::Symbol64TableEntry *Entry =
|
const MachOFormat::Symbol64TableEntry *Entry =
|
||||||
Obj->getSymbol64TableEntry( DRI);
|
Obj->getSymbol64TableEntry( DRI);
|
||||||
Symbol.StringIndex = Entry->StringIndex;
|
Symbol.StringIndex = Entry->StringIndex;
|
||||||
|
|
Loading…
Reference in New Issue