aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Object
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
commit6c1202c459ffa6d693ad92fa84e43902bc780bca (patch)
tree7b105f95ab50dfb164f274ae463085af780e3262 /lib/Object
parentcc5a6cb0a22736e133a17cf4de23e3d76de8058e (diff)
downloadexternal_llvm-6c1202c459ffa6d693ad92fa84e43902bc780bca.zip
external_llvm-6c1202c459ffa6d693ad92fa84e43902bc780bca.tar.gz
external_llvm-6c1202c459ffa6d693ad92fa84e43902bc780bca.tar.bz2
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183284 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Object')
-rw-r--r--lib/Object/COFFObjectFile.cpp6
-rw-r--r--lib/Object/MachOObjectFile.cpp13
-rw-r--r--lib/Object/Object.cpp5
3 files changed, 8 insertions, 16 deletions
diff --git a/lib/Object/COFFObjectFile.cpp b/lib/Object/COFFObjectFile.cpp
index f5b49ab..bc5958d 100644
--- a/lib/Object/COFFObjectFile.cpp
+++ b/lib/Object/COFFObjectFile.cpp
@@ -712,13 +712,11 @@ error_code COFFObjectFile::getRelocationOffset(DataRefImpl Rel,
Res = toRel(Rel)->VirtualAddress;
return object_error::success;
}
-error_code COFFObjectFile::getRelocationSymbol(DataRefImpl Rel,
- SymbolRef &Res) const {
+symbol_iterator COFFObjectFile::getRelocationSymbol(DataRefImpl Rel) const {
const coff_relocation* R = toRel(Rel);
DataRefImpl Symb;
Symb.p = reinterpret_cast<uintptr_t>(SymbolTable + R->SymbolTableIndex);
- Res = SymbolRef(Symb, this);
- return object_error::success;
+ return symbol_iterator(SymbolRef(Symb, this));
}
error_code COFFObjectFile::getRelocationType(DataRefImpl Rel,
uint64_t &Res) const {
diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp
index 654af08..bd5ea57 100644
--- a/lib/Object/MachOObjectFile.cpp
+++ b/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,
diff --git a/lib/Object/Object.cpp b/lib/Object/Object.cpp
index 3e2c78e..6941708 100644
--- a/lib/Object/Object.cpp
+++ b/lib/Object/Object.cpp
@@ -219,10 +219,7 @@ uint64_t LLVMGetRelocationOffset(LLVMRelocationIteratorRef RI) {
}
LLVMSymbolIteratorRef LLVMGetRelocationSymbol(LLVMRelocationIteratorRef RI) {
- SymbolRef ret;
- if (error_code ec = (*unwrap(RI))->getSymbol(ret))
- report_fatal_error(ec.message());
-
+ symbol_iterator ret = (*unwrap(RI))->getSymbol();
return wrap(new symbol_iterator(ret));
}