diff options
| author | Owen Anderson <resistor@mac.com> | 2011-10-12 22:21:32 +0000 |
|---|---|---|
| committer | Owen Anderson <resistor@mac.com> | 2011-10-12 22:21:32 +0000 |
| commit | fb02ecde5efc1c9c9f86bb998ff5a5f665e85966 (patch) | |
| tree | b200056abf5fca4439b710d367ae18ecff4a3be2 /llvm/lib | |
| parent | e3aef1d063edbe910c294821386553d67f42b16a (diff) | |
| download | bcm5719-llvm-fb02ecde5efc1c9c9f86bb998ff5a5f665e85966.tar.gz bcm5719-llvm-fb02ecde5efc1c9c9f86bb998ff5a5f665e85966.zip | |
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
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Object/MachOObjectFile.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index 21fd4b6915c..0d4dbd9ec45 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/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; } |

