summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/COFFObjectFile.cpp
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2019-01-03 08:08:23 +0000
committerMartin Storsjo <martin@martin.st>2019-01-03 08:08:23 +0000
commit74e7d26090be48fb99b2c69e48ec66b5007390f3 (patch)
treee90794304e9a8d6b5df48558c22925f582c04177 /llvm/lib/Object/COFFObjectFile.cpp
parent5ef47ad82ebb1d12a0789376e33a2827dbb7aa48 (diff)
downloadbcm5719-llvm-74e7d26090be48fb99b2c69e48ec66b5007390f3.tar.gz
bcm5719-llvm-74e7d26090be48fb99b2c69e48ec66b5007390f3.zip
[llvm-readobj] [COFF] Print the symbol index for relocations
There can be multiple local symbols with the same name (for e.g. comdat sections), and thus the symbol name itself isn't enough to disambiguate symbols. Differential Revision: https://reviews.llvm.org/D56140 llvm-svn: 350288
Diffstat (limited to 'llvm/lib/Object/COFFObjectFile.cpp')
-rw-r--r--llvm/lib/Object/COFFObjectFile.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp
index e17f0e2783e..fc1deeba339 100644
--- a/llvm/lib/Object/COFFObjectFile.cpp
+++ b/llvm/lib/Object/COFFObjectFile.cpp
@@ -1065,6 +1065,16 @@ COFFObjectFile::getSymbolAuxData(COFFSymbolRef Symbol) const {
return makeArrayRef(Aux, Symbol.getNumberOfAuxSymbols() * SymbolSize);
}
+uint32_t COFFObjectFile::getSymbolIndex(COFFSymbolRef Symbol) const {
+ uintptr_t Offset =
+ reinterpret_cast<uintptr_t>(Symbol.getRawPtr()) - getSymbolTable();
+ assert(Offset % getSymbolTableEntrySize() == 0 &&
+ "Symbol did not point to the beginning of a symbol");
+ size_t Index = Offset / getSymbolTableEntrySize();
+ assert(Index < getNumberOfSymbols());
+ return Index;
+}
+
std::error_code COFFObjectFile::getSectionName(const coff_section *Sec,
StringRef &Res) const {
StringRef Name;
OpenPOWER on IntegriCloud