[PATCH] D63350: [LLD] [COFF] Handle .eh_frame$symbol as associative comdat for MinGW

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 14 14:01:24 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL363456: [COFF] Handle .eh_frame$symbol as associative comdat for MinGW (authored by mstorsjo, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D63350?vs=204823&id=204845#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63350/new/

https://reviews.llvm.org/D63350

Files:
  lld/trunk/COFF/InputFiles.cpp
  lld/trunk/test/COFF/associative-comdat-mingw-i386.s


Index: lld/trunk/test/COFF/associative-comdat-mingw-i386.s
===================================================================
--- lld/trunk/test/COFF/associative-comdat-mingw-i386.s
+++ lld/trunk/test/COFF/associative-comdat-mingw-i386.s
@@ -0,0 +1,37 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -triple=i686-windows-gnu %s -filetype=obj -o %t.obj
+
+# RUN: lld-link -lldmingw -entry:main %t.obj -out:%t.exe
+# RUN: llvm-objdump -s %t.exe | FileCheck %s
+
+# Check that the .eh_frame comdat was included, even if it had no symbols,
+# due to associativity with the symbol _foo.
+
+# CHECK: Contents of section .eh_fram:
+# CHECK:  403000 42
+
+        .text
+        .def            _main;
+        .scl            2;
+        .type           32;
+        .endef
+        .globl          _main
+        .p2align        4, 0x90
+_main:
+        call            _foo
+        ret
+
+        .section        .eh_frame$foo,"dr"
+        .linkonce       discard
+        .byte           0x42
+
+        .def            _foo;
+        .scl            2;
+        .type           32;
+        .endef
+        .section        .text$foo,"xr",discard,foo
+        .globl          _foo
+        .p2align        4
+_foo:
+        ret
Index: lld/trunk/COFF/InputFiles.cpp
===================================================================
--- lld/trunk/COFF/InputFiles.cpp
+++ lld/trunk/COFF/InputFiles.cpp
@@ -288,6 +288,8 @@
   if (SC && SC->getOutputCharacteristics() & IMAGE_SCN_MEM_EXECUTE) {
     StringRef Name;
     COFFObj->getSymbolName(Sym, Name);
+    if (getMachineType() == I386)
+      Name.consume_front("_");
     PrevailingSectionMap[Name] = SectionNumber;
   }
 }
@@ -297,9 +299,10 @@
     const DenseMap<StringRef, uint32_t> &PrevailingSectionMap) {
   StringRef Name;
   COFFObj->getSymbolName(Sym, Name);
-  if (Name.consume_front(".pdata$") || Name.consume_front(".xdata$")) {
-    // For MinGW, treat .[px]data$<func> as implicitly associative to
-    // the symbol <func>.
+  if (Name.consume_front(".pdata$") || Name.consume_front(".xdata$") ||
+      Name.consume_front(".eh_frame$")) {
+    // For MinGW, treat .[px]data$<func> and .eh_frame$<func> as implicitly
+    // associative to the symbol <func>.
     auto ParentSym = PrevailingSectionMap.find(Name);
     if (ParentSym != PrevailingSectionMap.end())
       readAssociativeDefinition(Sym, Def, ParentSym->second);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63350.204845.patch
Type: text/x-patch
Size: 2384 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190614/9ff36a8c/attachment.bin>


More information about the llvm-commits mailing list