[lldb][COFF] Rewrite ParseSymtab to list both export and symbol tables
authorAlvin Wong <alvin@alvinhc.com>
Wed, 28 Sep 2022 09:40:37 +0000 (12:40 +0300)
committerMartin Storsjö <martin@martin.st>
Wed, 28 Sep 2022 09:57:10 +0000 (12:57 +0300)
commitbf0cda9ed2783a34efed3fc9804d784f7d1df242
treeec15658a11f4203dcc1eee585d312bd18308a6e2
parent759bedade53ebd34e0a9fb5356f35834c1af1c5b
[lldb][COFF] Rewrite ParseSymtab to list both export and symbol tables

This reimplements `ObjectFilePECOFF::ParseSymtab` to replace the manual
data extraction with what `COFFObjectFile` already provides. Also use
`SymTab::AddSymbol` instead of resizing the SymTab then assigning each
elements afterwards.

Previously, ParseSymTab loads symbols from both the COFF symbol table
and the export table, but if there are any entries in the export table,
it overwrites all the symbols already loaded from the COFF symbol table.
Due to the change to use AddSymbols, this no longer happens, and so the
SymTab now contains all symbols from both tables as expected.

The export symbols are now ordered by ordinal, instead of by the name
table order.

In its current state, it is possible for symbols in the COFF symbol
table to be duplicated by those in the export table. This behaviour will
be modified in a separate change.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D134196
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
lldb/test/Shell/ObjectFile/PECOFF/symbols-export-table.yaml [new file with mode: 0644]
llvm/include/llvm/Object/COFF.h