[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350288 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Martin Storsjo
2019-01-03 08:08:23 +00:00
parent 527dfff180
commit 0239fd32a4
6 changed files with 26 additions and 3 deletions
+10
View File
@@ -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;