Revert "[LLD] [COFF] Use StringTableBuilder to optimize the string table"
authorMartin Storsjö <martin@martin.st>
Tue, 21 Jun 2022 10:16:00 +0000 (13:16 +0300)
committerMartin Storsjö <martin@martin.st>
Tue, 21 Jun 2022 10:25:08 +0000 (13:25 +0300)
commit4d2eda2bb3156cee63ea486be34b01164b178e10
tree44b78297f6b8c07ac1ad623d120c1ed8ced77f78
parentab088de8734bc3875bd69fce6df47907b3a60f11
Revert "[LLD] [COFF] Use StringTableBuilder to optimize the string table"

This reverts commit 9ffeaaa0ea54307db309104696a0b6cce6ddda38.

This fixes debugging large executables with lldb and gdb.

When StringTableBuilder is used, the string offsets for any string
can point anywhere in the string table - while previously, all strings
were inserted in order (without deduplication and tail merging).

For symbols, there's no complications in encoding the string offset;
the offset is encoded as a raw 32 bit binary number in half of the
symbol name field.

For sections, the string table offset is written as
"/<decimaloffset>", but if the decimal offset would be larger than
7 digits, it's instead written as "//<base64offset>". Tools that
operate on object files can handle the base64 offset format, but
apparently neither lldb nor gdb expect that syntax when locating the
debug information section. Prior to the reverted commit, all long
section names were located at the start of the string table, so
their offset never exceeded the range for the decimal syntax.

Just reverting this change for now, as the actual benefit from it
was fairly modest.

Longer term, lld could write all long section names unoptimized
at the start of the string table, followed by all the strings for
symbol names, with deduplication and tail merging. And lldb and
gdb could be fixed to handle sections with the base64 offset syntax.

This fixes https://github.com/mstorsjo/llvm-mingw/issues/289.
lld/COFF/Writer.cpp