[PATCH] D134169: [LLD][COFF] Improve symbol table info for import thunk
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 20 01:03:35 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9509f4e6578b: [LLD][COFF] Improve symbol table info for import thunk (authored by alvinhochun, committed by mstorsjo).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134169/new/
https://reviews.llvm.org/D134169
Files:
lld/COFF/Writer.cpp
lld/test/COFF/symtab.test
Index: lld/test/COFF/symtab.test
===================================================================
--- lld/test/COFF/symtab.test
+++ lld/test/COFF/symtab.test
@@ -15,6 +15,15 @@
# CHECK-NEXT: Value: 80
# CHECK-NEXT: Section: .text (1)
# CHECK-NEXT: BaseType: Null (0x0)
+# CHECK-NEXT: ComplexType: Function (0x2)
+# CHECK-NEXT: StorageClass: External (0x2)
+# CHECK-NEXT: AuxSymbolCount: 0
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name: __imp_MessageBoxA
+# CHECK-NEXT: Value:
+# CHECK-NEXT: Section: .rdata (2)
+# CHECK-NEXT: BaseType: Null (0x0)
# CHECK-NEXT: ComplexType: Null (0x0)
# CHECK-NEXT: StorageClass: External (0x2)
# CHECK-NEXT: AuxSymbolCount: 0
@@ -24,6 +33,15 @@
# CHECK-NEXT: Value: 64
# CHECK-NEXT: Section: .text (1)
# CHECK-NEXT: BaseType: Null (0x0)
+# CHECK-NEXT: ComplexType: Function (0x2)
+# CHECK-NEXT: StorageClass: External (0x2)
+# CHECK-NEXT: AuxSymbolCount: 0
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name: __imp_ExitProcess
+# CHECK-NEXT: Value:
+# CHECK-NEXT: Section: .rdata (2)
+# CHECK-NEXT: BaseType: Null (0x0)
# CHECK-NEXT: ComplexType: Null (0x0)
# CHECK-NEXT: StorageClass: External (0x2)
# CHECK-NEXT: AuxSymbolCount: 0
Index: lld/COFF/Writer.cpp
===================================================================
--- lld/COFF/Writer.cpp
+++ lld/COFF/Writer.cpp
@@ -1179,6 +1179,10 @@
COFFSymbolRef ref = d->getCOFFSymbol();
sym.Type = ref.getType();
sym.StorageClass = ref.getStorageClass();
+ } else if (def->kind() == Symbol::DefinedImportThunkKind) {
+ sym.Type = (IMAGE_SYM_DTYPE_FUNCTION << SCT_COMPLEX_TYPE_SHIFT) |
+ IMAGE_SYM_TYPE_NULL;
+ sym.StorageClass = IMAGE_SYM_CLASS_EXTERNAL;
} else {
sym.Type = IMAGE_SYM_TYPE_NULL;
sym.StorageClass = IMAGE_SYM_CLASS_EXTERNAL;
@@ -1225,6 +1229,14 @@
if (Optional<coff_symbol16> sym = createSymbol(d))
outputSymtab.push_back(*sym);
+
+ if (auto *dthunk = dyn_cast<DefinedImportThunk>(d)) {
+ if (!dthunk->wrappedSym->writtenToSymtab) {
+ dthunk->wrappedSym->writtenToSymtab = true;
+ if (Optional<coff_symbol16> sym = createSymbol(dthunk->wrappedSym))
+ outputSymtab.push_back(*sym);
+ }
+ }
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134169.461482.patch
Type: text/x-patch
Size: 2402 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220920/385bd70f/attachment.bin>
More information about the llvm-commits
mailing list