This is an archive of the discontinued LLVM Phabricator instance.

[PDB] Write public symbol records and the publics hash table
ClosedPublic

Authored by rnk on Jul 25 2017, 6:21 PM.

Details

Diff Detail

Repository
rL LLVM

Event Timeline

rnk created this revision.Jul 25 2017, 6:21 PM
ruiu added inline comments.Jul 25 2017, 7:53 PM
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).

pcc added a subscriber: pcc.Jul 25 2017, 8:49 PM

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.

rnk added inline comments.Jul 26 2017, 10:07 AM
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.

rnk updated this revision to Diff 108327.Jul 26 2017, 10:53 AM
rnk marked 6 inline comments as done.
  • 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.

ruiu accepted this revision.Jul 26 2017, 6:04 PM

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.

This revision is now accepted and ready to land.Jul 26 2017, 6:04 PM
rnk marked an inline comment as done.Jul 27 2017, 11:13 AM
This revision was automatically updated to reflect the committed changes.