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.
Details
Diff Detail
Event Timeline
Neither of the tools that print relocations currently, llvm-readobj, llvm-objdump or yaml2obj, disambiguate between relocations pointing to different symbols with the same name.
include/llvm/Object/COFF.h | ||
---|---|---|
438 | Instead of storing an index as a member, can you compute it when you need it from the offset from the beginning of a symbol table? |
Btw, do you think the index should be printed in hex? That's what dumpbin -relocations does.
include/llvm/Object/COFF.h | ||
---|---|---|
438 | Yes, that'd be possible, but COFFSymbolRef doesn't have a reference to either the start of the symbol table or the surrounding COFFObjectFile, so it'd have to be a getIndexOf(COFFSymbolRef) member in COFFObjectFile in that case. |
Removed the extra member from COFFSymbol, added a method to COFFObjectFile for calculating it instead.
The question about printing hex vs decimal is still open for opinions.
tools/llvm-readobj/COFFDumper.cpp | ||
---|---|---|
1381 | one minor concern: if I understand correctly if the symbol is not found (Symbol == Obj->symbol_end()) this code still will print SymbolIndex = 0. Maybe we can do smth similar to how SymbolName is handled ? |
tools/llvm-readobj/COFFDumper.cpp | ||
---|---|---|
1381 | Sure, I guess -1 is the only sensible thing to print then. The index can technically be any uint32_t, so storing it in a local int64_t to allow for -1 should be safe then. |
Instead of storing an index as a member, can you compute it when you need it from the offset from the beginning of a symbol table?