MSVC link.exe records all external symbol names in the publics stream.
It provides similar functionality to an ELF .symtab.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lld/COFF/PDB.cpp | ||
---|---|---|
558 ↗ | (On Diff #108196) | I think it is a good idea to add this (except the check for isCodeView) as isLive() to SymbolBody class. |
570–575 ↗ | (On Diff #108196) | You can remove COFFRef local variable if you change this code to if (auto *D = dyn_cast<DefinedCOFF>(Def)) if (D->getCOFFSymbol().isSection()) return None; |
580 ↗ | (On Diff #108196) | and if (auto *D = dyn_cast<DefinedCOFF>(Def)) { if (D->getCOFFSymbol().isFunctionDefinition()) ... |
lld/COFF/SymbolTable.h | ||
113–114 ↗ | (On Diff #108196) | Instead of making this public, I'd define forEachSymbol(std::function<void(Symbol *)> Fn). |
Test case?
Also, can we remove the logic to write out the non-standard PE symbol table once this lands?
lld/COFF/PDB.cpp | ||
---|---|---|
551 ↗ | (On Diff #108196) | I guess this should talk about PDBs rather than COFF symbol tables. |
574 ↗ | (On Diff #108196) | Can section symbols appear in SymbolTable::Symtab? I believe that it only contains external symbols. |
609 ↗ | (On Diff #108196) | http://llvm-cs.pcc.me.uk/tools/lld/COFF/SymbolTable.h/rSymtab It doesn't appear that this can ever be null. |
613 ↗ | (On Diff #108196) | Is the WrittenToPDB check necessary? I believe that each symbol should only appear once in SymbolTable::Symtab. |
lld/COFF/PDB.cpp | ||
---|---|---|
558 ↗ | (On Diff #108196) | Makes sense, will do. |
613 ↗ | (On Diff #108196) | True, this is a hold-over from when I iterated each symbol in each object file, like the COFF symbol table generation code does. The nice thing about that approach is that it emits symbols in input file order, whereas I have to do a separate sorting step to keep the output deterministic. |
622 ↗ | (On Diff #108196) | I suppose we can use std::sort over std::stable_sort since external names must be unique. We did just take them out of a hash table, after all. |
- comments
lld/COFF/PDB.cpp | ||
---|---|---|
551 ↗ | (On Diff #108196) | I changed this to check for a valid chunk instead. Absolute and synthetic symbols are a risk here because they may not have chunks, so we cannot get their OutputSection, which means they'll have no SectionIndex. |
574 ↗ | (On Diff #108196) | I think not, this must be a hold-over from the object file iteration approach. |
LGTM
lld/COFF/SymbolTable.h | ||
---|---|---|
112 ↗ | (On Diff #108327) | Since you are not using Pair.first.val() at least at the moment, pass only Pair.second. |