[PATCH] D113866: [LLD] [COFF] Omit IMAGE_SYM_CLASS_LABEL symbols from the PE symbol table
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 14 14:46:49 PST 2021
mstorsjo created this revision.
mstorsjo added reviewers: rnk, efriedma.
mstorsjo requested review of this revision.
Herald added a project: LLVM.
Also omit section definition symbols. This matches the condition for
symbols to omit from map files.
If we start producing lots of IMAGE_SYM_CLASS_LABEL symbols due to
D113865 <https://reviews.llvm.org/D113865>, it inflates the size of mingw style default linked binaries
(with dwarf debug info and a regular PE symbol table) a fair bit
(by 14% in one test).
By omitting these symbols, the size remains the same as before, and
by omitting the section definition symbols we further shrink the
mingw style unstripped binaries by 14% in one test.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D113866
Files:
lld/COFF/Writer.cpp
lld/test/COFF/strtab-size.s
lld/test/COFF/symtab.test
Index: lld/test/COFF/symtab.test
===================================================================
--- lld/test/COFF/symtab.test
+++ lld/test/COFF/symtab.test
@@ -11,33 +11,6 @@
# CHECK: Symbols [
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: .text
-# CHECK-NEXT: Value: 0
-# CHECK-NEXT: Section: .text (1)
-# CHECK-NEXT: BaseType: Null (0x0)
-# CHECK-NEXT: ComplexType: Null (0x0)
-# CHECK-NEXT: StorageClass: Static (0x3)
-# CHECK-NEXT: AuxSymbolCount: 0
-# CHECK-NEXT: }
-# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: .text2
-# CHECK-NEXT: Value: 0
-# CHECK-NEXT: Section: .text (1)
-# CHECK-NEXT: BaseType: Null (0x0)
-# CHECK-NEXT: ComplexType: Null (0x0)
-# CHECK-NEXT: StorageClass: Static (0x3)
-# CHECK-NEXT: AuxSymbolCount: 0
-# CHECK-NEXT: }
-# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: .data
-# CHECK-NEXT: Value: 0
-# CHECK-NEXT: Section: .data (3)
-# CHECK-NEXT: BaseType: Null (0x0)
-# CHECK-NEXT: ComplexType: Null (0x0)
-# CHECK-NEXT: StorageClass: Static (0x3)
-# CHECK-NEXT: AuxSymbolCount: 0
-# CHECK-NEXT: }
-# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: MessageBoxA
# CHECK-NEXT: Value: 80
# CHECK-NEXT: Section: .text (1)
@@ -235,4 +208,10 @@
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_NULL
StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: .Ltemp_symbol
+ Value: 1
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_LABEL
...
Index: lld/test/COFF/strtab-size.s
===================================================================
--- lld/test/COFF/strtab-size.s
+++ lld/test/COFF/strtab-size.s
@@ -213,4 +213,5 @@
sym192:
sym193:
sym194:
+sym195:
ret
Index: lld/COFF/Writer.cpp
===================================================================
--- lld/COFF/Writer.cpp
+++ lld/COFF/Writer.cpp
@@ -1210,6 +1210,13 @@
auto *d = dyn_cast_or_null<Defined>(b);
if (!d || d->writtenToSymtab)
continue;
+ auto *dc = dyn_cast_or_null<DefinedCOFF>(d);
+ if (dc) {
+ COFFSymbolRef symRef = dc->getCOFFSymbol();
+ if (symRef.isSectionDefinition() ||
+ symRef.getStorageClass() == COFF::IMAGE_SYM_CLASS_LABEL)
+ continue;
+ }
d->writtenToSymtab = true;
if (Optional<coff_symbol16> sym = createSymbol(d))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113866.387138.patch
Type: text/x-patch
Size: 2517 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211114/7cc193a8/attachment.bin>
More information about the llvm-commits
mailing list