summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/MachOObjectFile.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-06-05 01:33:53 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-06-05 01:33:53 +0000
commit806f00649090e81ed478441e3edcddaef1176ee0 (patch)
treed568409a0c21e6b767feb6bdb9a1b27705505c71 /llvm/lib/Object/MachOObjectFile.cpp
parente6c0144208a4352c7c50616508081278c2ee5f88 (diff)
downloadbcm5719-llvm-806f00649090e81ed478441e3edcddaef1176ee0.tar.gz
bcm5719-llvm-806f00649090e81ed478441e3edcddaef1176ee0.zip
Handle relocations that don't point to symbols.
In ELF (as in MachO), not all relocations point to symbols. Represent this properly by using a symbol_iterator instead of a SymbolRef. Update llvm-readobj ELF's dumper to handle relocatios without symbols. llvm-svn: 183284
Diffstat (limited to 'llvm/lib/Object/MachOObjectFile.cpp')
-rw-r--r--llvm/lib/Object/MachOObjectFile.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp
index 654af081f9e..bd5ea57c1f5 100644
--- a/llvm/lib/Object/MachOObjectFile.cpp
+++ b/llvm/lib/Object/MachOObjectFile.cpp
@@ -869,15 +869,13 @@ error_code MachOObjectFile::getRelocationOffset(DataRefImpl Rel,
return object_error::success;
}
-error_code
-MachOObjectFile::getRelocationSymbol(DataRefImpl Rel, SymbolRef &Res) const {
+symbol_iterator
+MachOObjectFile::getRelocationSymbol(DataRefImpl Rel) const {
macho::RelocationEntry RE = getRelocation(Rel);
uint32_t SymbolIdx = getPlainRelocationSymbolNum(RE);
bool isExtern = getPlainRelocationExternal(RE);
- if (!isExtern) {
- Res = *end_symbols();
- return object_error::success;
- }
+ if (!isExtern)
+ return end_symbols();
macho::SymtabLoadCommand S = getSymtabLoadCommand();
unsigned SymbolTableEntrySize = is64Bit() ?
@@ -886,8 +884,7 @@ MachOObjectFile::getRelocationSymbol(DataRefImpl Rel, SymbolRef &Res) const {
uint64_t Offset = S.SymbolTableOffset + SymbolIdx * SymbolTableEntrySize;
DataRefImpl Sym;
Sym.p = reinterpret_cast<uintptr_t>(getPtr(this, Offset));
- Res = SymbolRef(Sym, this);
- return object_error::success;
+ return symbol_iterator(SymbolRef(Sym, this));
}
error_code MachOObjectFile::getRelocationType(DataRefImpl Rel,
OpenPOWER on IntegriCloud