MSVC link.exe records all external symbol names in the publics stream.
It provides similar functionality to an ELF .symtab.
Details
Diff Detail
- Build Status
Buildable 8593 Build 8593: arc lint + arc unit
Event Timeline
lld/COFF/PDB.cpp | ||
---|---|---|
558 | I think it is a good idea to add this (except the check for isCodeView) as isLive() to SymbolBody class. | |
570–575 | 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 | and if (auto *D = dyn_cast<DefinedCOFF>(Def)) { if (D->getCOFFSymbol().isFunctionDefinition()) ... | |
lld/COFF/SymbolTable.h | ||
113–114 | 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 | I guess this should talk about PDBs rather than COFF symbol tables. | |
574 | Can section symbols appear in SymbolTable::Symtab? I believe that it only contains external symbols. | |
609 | http://llvm-cs.pcc.me.uk/tools/lld/COFF/SymbolTable.h/rSymtab It doesn't appear that this can ever be null. | |
613 | Is the WrittenToPDB check necessary? I believe that each symbol should only appear once in SymbolTable::Symtab. |
lld/COFF/PDB.cpp | ||
---|---|---|
558 | Makes sense, will do. | |
613 | 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 | 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 | 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 | I think not, this must be a hold-over from the object file iteration approach. |
LGTM
lld/COFF/SymbolTable.h | ||
---|---|---|
112 | Since you are not using Pair.first.val() at least at the moment, pass only Pair.second. |
I guess this should talk about PDBs rather than COFF symbol tables.