summaryrefslogtreecommitdiff
path: root/lib/Object
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2011-10-12 22:21:32 +0000
committerOwen Anderson <resistor@mac.com>2011-10-12 22:21:32 +0000
commitcd74988fb94ffc180196fed9aa2c8ee548915f86 (patch)
treee2a185ca0d1f2654eebc07806609db0cd1c650b7 /lib/Object
parent18ead6b587159993b340ad4e2e2c5fed76e978c0 (diff)
downloadllvm-cd74988fb94ffc180196fed9aa2c8ee548915f86.tar.gz
llvm-cd74988fb94ffc180196fed9aa2c8ee548915f86.tar.bz2
llvm-cd74988fb94ffc180196fed9aa2c8ee548915f86.tar.xz
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141822 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Object')
-rw-r--r--lib/Object/MachOObjectFile.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp
index 21fd4b6915..0d4dbd9ec4 100644
--- a/lib/Object/MachOObjectFile.cpp
+++ b/lib/Object/MachOObjectFile.cpp
@@ -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;
}