mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-22 10:24:26 +00:00
Use getLoadCommandInfo instead of MachOObj->getLoadCommandInfo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178989 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -115,7 +115,7 @@ MachOObjectFile::getSegment64LoadCommand(LoadCommandInfo LCI) const {
|
|||||||
void MachOObjectFile::moveToNextSymbol(DataRefImpl &DRI) const {
|
void MachOObjectFile::moveToNextSymbol(DataRefImpl &DRI) const {
|
||||||
uint32_t LoadCommandCount = MachOObj->getHeader().NumLoadCommands;
|
uint32_t LoadCommandCount = MachOObj->getHeader().NumLoadCommands;
|
||||||
while (DRI.d.a < LoadCommandCount) {
|
while (DRI.d.a < LoadCommandCount) {
|
||||||
LoadCommandInfo LCI = MachOObj->getLoadCommandInfo(DRI.d.a);
|
LoadCommandInfo LCI = getLoadCommandInfo(DRI.d.a);
|
||||||
if (LCI.Command.Type == macho::LCT_Symtab) {
|
if (LCI.Command.Type == macho::LCT_Symtab) {
|
||||||
const MachOFormat::SymtabLoadCommand *SymtabLoadCmd =
|
const MachOFormat::SymtabLoadCommand *SymtabLoadCmd =
|
||||||
getSymtabLoadCommand(LCI);
|
getSymtabLoadCommand(LCI);
|
||||||
@ -130,7 +130,7 @@ void MachOObjectFile::moveToNextSymbol(DataRefImpl &DRI) const {
|
|||||||
|
|
||||||
const MachOFormat::SymbolTableEntry *
|
const MachOFormat::SymbolTableEntry *
|
||||||
MachOObjectFile::getSymbolTableEntry(DataRefImpl DRI) const {
|
MachOObjectFile::getSymbolTableEntry(DataRefImpl DRI) const {
|
||||||
LoadCommandInfo LCI = MachOObj->getLoadCommandInfo(DRI.d.a);
|
LoadCommandInfo LCI = getLoadCommandInfo(DRI.d.a);
|
||||||
const MachOFormat::SymtabLoadCommand *SymtabLoadCmd =
|
const MachOFormat::SymtabLoadCommand *SymtabLoadCmd =
|
||||||
getSymtabLoadCommand(LCI);
|
getSymtabLoadCommand(LCI);
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ MachOObjectFile::getSymbolTableEntry(DataRefImpl DRI,
|
|||||||
|
|
||||||
const MachOFormat::Symbol64TableEntry*
|
const MachOFormat::Symbol64TableEntry*
|
||||||
MachOObjectFile::getSymbol64TableEntry(DataRefImpl DRI) const {
|
MachOObjectFile::getSymbol64TableEntry(DataRefImpl DRI) const {
|
||||||
LoadCommandInfo LCI = MachOObj->getLoadCommandInfo(DRI.d.a);
|
LoadCommandInfo LCI = getLoadCommandInfo(DRI.d.a);
|
||||||
const MachOFormat::SymtabLoadCommand *SymtabLoadCmd =
|
const MachOFormat::SymtabLoadCommand *SymtabLoadCmd =
|
||||||
getSymtabLoadCommand(LCI);
|
getSymtabLoadCommand(LCI);
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ error_code MachOObjectFile::getSymbolNext(DataRefImpl DRI,
|
|||||||
|
|
||||||
error_code MachOObjectFile::getSymbolName(DataRefImpl DRI,
|
error_code MachOObjectFile::getSymbolName(DataRefImpl DRI,
|
||||||
StringRef &Result) const {
|
StringRef &Result) const {
|
||||||
LoadCommandInfo LCI = MachOObj->getLoadCommandInfo(DRI.d.a);
|
LoadCommandInfo LCI = getLoadCommandInfo(DRI.d.a);
|
||||||
const MachOFormat::SymtabLoadCommand *SymtabLoadCmd =
|
const MachOFormat::SymtabLoadCommand *SymtabLoadCmd =
|
||||||
getSymtabLoadCommand(LCI);
|
getSymtabLoadCommand(LCI);
|
||||||
|
|
||||||
@ -478,7 +478,7 @@ StringRef MachOObjectFile::getLoadName() const {
|
|||||||
void MachOObjectFile::moveToNextSection(DataRefImpl &DRI) const {
|
void MachOObjectFile::moveToNextSection(DataRefImpl &DRI) const {
|
||||||
uint32_t LoadCommandCount = MachOObj->getHeader().NumLoadCommands;
|
uint32_t LoadCommandCount = MachOObj->getHeader().NumLoadCommands;
|
||||||
while (DRI.d.a < LoadCommandCount) {
|
while (DRI.d.a < LoadCommandCount) {
|
||||||
LoadCommandInfo LCI = MachOObj->getLoadCommandInfo(DRI.d.a);
|
LoadCommandInfo LCI = getLoadCommandInfo(DRI.d.a);
|
||||||
if (LCI.Command.Type == macho::LCT_Segment) {
|
if (LCI.Command.Type == macho::LCT_Segment) {
|
||||||
const MachOFormat::SegmentLoadCommand *SegmentLoadCmd =
|
const MachOFormat::SegmentLoadCommand *SegmentLoadCmd =
|
||||||
getSegmentLoadCommand(LCI);
|
getSegmentLoadCommand(LCI);
|
||||||
@ -504,7 +504,8 @@ error_code MachOObjectFile::getSectionNext(DataRefImpl DRI,
|
|||||||
return object_error::success;
|
return object_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is64BitLoadCommand(const MachOObject *MachOObj, DataRefImpl DRI) {
|
static bool is64BitLoadCommand(const MachOObjectFile *MachOObj,
|
||||||
|
DataRefImpl DRI) {
|
||||||
LoadCommandInfo LCI = MachOObj->getLoadCommandInfo(DRI.d.a);
|
LoadCommandInfo LCI = MachOObj->getLoadCommandInfo(DRI.d.a);
|
||||||
if (LCI.Command.Type == macho::LCT_Segment64)
|
if (LCI.Command.Type == macho::LCT_Segment64)
|
||||||
return true;
|
return true;
|
||||||
@ -513,8 +514,8 @@ static bool is64BitLoadCommand(const MachOObject *MachOObj, DataRefImpl DRI) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const MachOFormat::Section *MachOObjectFile::getSection(DataRefImpl DRI) const {
|
const MachOFormat::Section *MachOObjectFile::getSection(DataRefImpl DRI) const {
|
||||||
assert(!is64BitLoadCommand(MachOObj.get(), DRI));
|
assert(!is64BitLoadCommand(this, DRI));
|
||||||
LoadCommandInfo LCI = MachOObj->getLoadCommandInfo(DRI.d.a);
|
LoadCommandInfo LCI = getLoadCommandInfo(DRI.d.a);
|
||||||
unsigned SectionOffset = LCI.Offset + sizeof(macho::SegmentLoadCommand) +
|
unsigned SectionOffset = LCI.Offset + sizeof(macho::SegmentLoadCommand) +
|
||||||
DRI.d.b * sizeof(MachOFormat::Section);
|
DRI.d.b * sizeof(MachOFormat::Section);
|
||||||
StringRef Data = MachOObj->getData(SectionOffset, sizeof(MachOFormat::Section));
|
StringRef Data = MachOObj->getData(SectionOffset, sizeof(MachOFormat::Section));
|
||||||
@ -530,8 +531,8 @@ std::size_t MachOObjectFile::getSectionIndex(DataRefImpl Sec) const {
|
|||||||
|
|
||||||
const MachOFormat::Section64 *
|
const MachOFormat::Section64 *
|
||||||
MachOObjectFile::getSection64(DataRefImpl DRI) const {
|
MachOObjectFile::getSection64(DataRefImpl DRI) const {
|
||||||
assert(is64BitLoadCommand(MachOObj.get(), DRI));
|
assert(is64BitLoadCommand(this, DRI));
|
||||||
LoadCommandInfo LCI = MachOObj->getLoadCommandInfo(DRI.d.a);
|
LoadCommandInfo LCI = getLoadCommandInfo(DRI.d.a);
|
||||||
unsigned SectionOffset = LCI.Offset + sizeof(macho::Segment64LoadCommand) +
|
unsigned SectionOffset = LCI.Offset + sizeof(macho::Segment64LoadCommand) +
|
||||||
DRI.d.b * sizeof(MachOFormat::Section64);
|
DRI.d.b * sizeof(MachOFormat::Section64);
|
||||||
StringRef Data = MachOObj->getData(SectionOffset, sizeof(MachOFormat::Section64));
|
StringRef Data = MachOObj->getData(SectionOffset, sizeof(MachOFormat::Section64));
|
||||||
@ -547,7 +548,7 @@ static StringRef parseSegmentOrSectionName(const char *P) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ArrayRef<char> MachOObjectFile::getSectionRawName(DataRefImpl DRI) const {
|
ArrayRef<char> MachOObjectFile::getSectionRawName(DataRefImpl DRI) const {
|
||||||
if (is64BitLoadCommand(MachOObj.get(), DRI)) {
|
if (is64BitLoadCommand(this, DRI)) {
|
||||||
const MachOFormat::Section64 *sec = getSection64(DRI);
|
const MachOFormat::Section64 *sec = getSection64(DRI);
|
||||||
return ArrayRef<char>(sec->Name);
|
return ArrayRef<char>(sec->Name);
|
||||||
} else {
|
} else {
|
||||||
@ -565,7 +566,7 @@ error_code MachOObjectFile::getSectionName(DataRefImpl DRI,
|
|||||||
|
|
||||||
ArrayRef<char>
|
ArrayRef<char>
|
||||||
MachOObjectFile::getSectionRawFinalSegmentName(DataRefImpl Sec) const {
|
MachOObjectFile::getSectionRawFinalSegmentName(DataRefImpl Sec) const {
|
||||||
if (is64BitLoadCommand(MachOObj.get(), Sec)) {
|
if (is64BitLoadCommand(this, Sec)) {
|
||||||
const MachOFormat::Section64 *sec = getSection64(Sec);
|
const MachOFormat::Section64 *sec = getSection64(Sec);
|
||||||
return ArrayRef<char>(sec->SegmentName, 16);
|
return ArrayRef<char>(sec->SegmentName, 16);
|
||||||
} else {
|
} else {
|
||||||
@ -581,7 +582,7 @@ StringRef MachOObjectFile::getSectionFinalSegmentName(DataRefImpl DRI) const {
|
|||||||
|
|
||||||
error_code MachOObjectFile::getSectionAddress(DataRefImpl DRI,
|
error_code MachOObjectFile::getSectionAddress(DataRefImpl DRI,
|
||||||
uint64_t &Result) const {
|
uint64_t &Result) const {
|
||||||
if (is64BitLoadCommand(MachOObj.get(), DRI)) {
|
if (is64BitLoadCommand(this, DRI)) {
|
||||||
const MachOFormat::Section64 *Sect = getSection64(DRI);
|
const MachOFormat::Section64 *Sect = getSection64(DRI);
|
||||||
Result = Sect->Address;
|
Result = Sect->Address;
|
||||||
} else {
|
} else {
|
||||||
@ -593,7 +594,7 @@ error_code MachOObjectFile::getSectionAddress(DataRefImpl DRI,
|
|||||||
|
|
||||||
error_code MachOObjectFile::getSectionSize(DataRefImpl DRI,
|
error_code MachOObjectFile::getSectionSize(DataRefImpl DRI,
|
||||||
uint64_t &Result) const {
|
uint64_t &Result) const {
|
||||||
if (is64BitLoadCommand(MachOObj.get(), DRI)) {
|
if (is64BitLoadCommand(this, DRI)) {
|
||||||
const MachOFormat::Section64 *Sect = getSection64(DRI);
|
const MachOFormat::Section64 *Sect = getSection64(DRI);
|
||||||
Result = Sect->Size;
|
Result = Sect->Size;
|
||||||
} else {
|
} else {
|
||||||
@ -605,7 +606,7 @@ error_code MachOObjectFile::getSectionSize(DataRefImpl DRI,
|
|||||||
|
|
||||||
error_code MachOObjectFile::getSectionContents(DataRefImpl DRI,
|
error_code MachOObjectFile::getSectionContents(DataRefImpl DRI,
|
||||||
StringRef &Result) const {
|
StringRef &Result) const {
|
||||||
if (is64BitLoadCommand(MachOObj.get(), DRI)) {
|
if (is64BitLoadCommand(this, DRI)) {
|
||||||
const MachOFormat::Section64 *Sect = getSection64(DRI);
|
const MachOFormat::Section64 *Sect = getSection64(DRI);
|
||||||
Result = MachOObj->getData(Sect->Offset, Sect->Size);
|
Result = MachOObj->getData(Sect->Offset, Sect->Size);
|
||||||
} else {
|
} else {
|
||||||
@ -617,7 +618,7 @@ error_code MachOObjectFile::getSectionContents(DataRefImpl DRI,
|
|||||||
|
|
||||||
error_code MachOObjectFile::getSectionAlignment(DataRefImpl DRI,
|
error_code MachOObjectFile::getSectionAlignment(DataRefImpl DRI,
|
||||||
uint64_t &Result) const {
|
uint64_t &Result) const {
|
||||||
if (is64BitLoadCommand(MachOObj.get(), DRI)) {
|
if (is64BitLoadCommand(this, DRI)) {
|
||||||
const MachOFormat::Section64 *Sect = getSection64(DRI);
|
const MachOFormat::Section64 *Sect = getSection64(DRI);
|
||||||
Result = uint64_t(1) << Sect->Align;
|
Result = uint64_t(1) << Sect->Align;
|
||||||
} else {
|
} else {
|
||||||
@ -629,7 +630,7 @@ error_code MachOObjectFile::getSectionAlignment(DataRefImpl DRI,
|
|||||||
|
|
||||||
error_code MachOObjectFile::isSectionText(DataRefImpl DRI,
|
error_code MachOObjectFile::isSectionText(DataRefImpl DRI,
|
||||||
bool &Result) const {
|
bool &Result) const {
|
||||||
if (is64BitLoadCommand(MachOObj.get(), DRI)) {
|
if (is64BitLoadCommand(this, DRI)) {
|
||||||
const MachOFormat::Section64 *Sect = getSection64(DRI);
|
const MachOFormat::Section64 *Sect = getSection64(DRI);
|
||||||
Result = Sect->Flags & macho::SF_PureInstructions;
|
Result = Sect->Flags & macho::SF_PureInstructions;
|
||||||
} else {
|
} else {
|
||||||
@ -730,7 +731,7 @@ relocation_iterator MachOObjectFile::getSectionRelBegin(DataRefImpl Sec) const {
|
|||||||
}
|
}
|
||||||
relocation_iterator MachOObjectFile::getSectionRelEnd(DataRefImpl Sec) const {
|
relocation_iterator MachOObjectFile::getSectionRelEnd(DataRefImpl Sec) const {
|
||||||
uint32_t last_reloc;
|
uint32_t last_reloc;
|
||||||
if (is64BitLoadCommand(MachOObj.get(), Sec)) {
|
if (is64BitLoadCommand(this, Sec)) {
|
||||||
const MachOFormat::Section64 *Sect = getSection64(Sec);
|
const MachOFormat::Section64 *Sect = getSection64(Sec);
|
||||||
last_reloc = Sect->NumRelocationTableEntries;
|
last_reloc = Sect->NumRelocationTableEntries;
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user