mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
sectionContainsSymbol needs to be based on VMA's rather than section indices to properly account for files with segment load commands that contain no sections.
llvm-svn: 141822
This commit is contained in:
parent
22c39edd2e
commit
6e41e4318d
@ -449,15 +449,30 @@ error_code MachOObjectFile::isSectionBSS(DataRefImpl DRI,
|
||||
error_code MachOObjectFile::sectionContainsSymbol(DataRefImpl Sec,
|
||||
DataRefImpl Symb,
|
||||
bool &Result) const {
|
||||
SymbolRef::SymbolType ST;
|
||||
getSymbolType(Symb, ST);
|
||||
if (ST == SymbolRef::ST_External) {
|
||||
Result = false;
|
||||
return object_error::success;
|
||||
}
|
||||
|
||||
uint64_t SectBegin, SectEnd;
|
||||
getSectionAddress(Sec, SectBegin);
|
||||
getSectionSize(Sec, SectEnd);
|
||||
SectEnd += SectBegin;
|
||||
|
||||
if (MachOObj->is64Bit()) {
|
||||
InMemoryStruct<macho::Symbol64TableEntry> Entry;
|
||||
getSymbol64TableEntry(Symb, Entry);
|
||||
Result = Entry->SectionIndex == 1 + Sec.d.a + Sec.d.b;
|
||||
uint64_t SymAddr= Entry->Value;
|
||||
Result = (SymAddr >= SectBegin) && (SymAddr < SectEnd);
|
||||
} else {
|
||||
InMemoryStruct<macho::SymbolTableEntry> Entry;
|
||||
getSymbolTableEntry(Symb, Entry);
|
||||
Result = Entry->SectionIndex == 1 + Sec.d.a + Sec.d.b;
|
||||
uint64_t SymAddr= Entry->Value;
|
||||
Result = (SymAddr >= SectBegin) && (SymAddr < SectEnd);
|
||||
}
|
||||
|
||||
return object_error::success;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user