[llvm] r348177 - [COFF] Don't mark mingw .eh_frame sections writable

Martin Storsjo via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 3 12:02:06 PST 2018


Author: mstorsjo
Date: Mon Dec  3 12:02:05 2018
New Revision: 348177

URL: http://llvm.org/viewvc/llvm-project?rev=348177&view=rev
Log:
[COFF] Don't mark mingw .eh_frame sections writable

This improves compatibility with GCC produced object files, where
the .eh_frame sections are read only. With mixed flags for the
involved .eh_frame sections, LLD creates two separate .eh_frame
sections in the output binary, one for each flag combination,
while ld.bfd probably merges them.

The previous setup of flags can be traced back to SVN r79346.

Differential Revision: https://reviews.llvm.org/D55209

Modified:
    llvm/trunk/lib/MC/MCObjectFileInfo.cpp
    llvm/trunk/test/MC/COFF/eh-frame.s

Modified: llvm/trunk/lib/MC/MCObjectFileInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectFileInfo.cpp?rev=348177&r1=348176&r2=348177&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectFileInfo.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectFileInfo.cpp Mon Dec  3 12:02:05 2018
@@ -479,10 +479,10 @@ void MCObjectFileInfo::initELFMCObjectFi
 }
 
 void MCObjectFileInfo::initCOFFMCObjectFileInfo(const Triple &T) {
-  EHFrameSection = Ctx->getCOFFSection(
-      ".eh_frame", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
-                       COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE,
-      SectionKind::getData());
+  EHFrameSection =
+      Ctx->getCOFFSection(".eh_frame", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
+                                           COFF::IMAGE_SCN_MEM_READ,
+                          SectionKind::getData());
 
   // Set the `IMAGE_SCN_MEM_16BIT` flag when compiling for thumb mode.  This is
   // used to indicate to the linker that the text segment contains thumb instructions

Modified: llvm/trunk/test/MC/COFF/eh-frame.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/eh-frame.s?rev=348177&r1=348176&r2=348177&view=diff
==============================================================================
--- llvm/trunk/test/MC/COFF/eh-frame.s (original)
+++ llvm/trunk/test/MC/COFF/eh-frame.s Mon Dec  3 12:02:05 2018
@@ -12,3 +12,16 @@ _main:
 	.cfi_endproc
 
 // CHECK:    Name: .eh_frame
+// CHECK-NEXT:    VirtualSize:
+// CHECK-NEXT:    VirtualAddress:
+// CHECK-NEXT:    RawDataSize:
+// CHECK-NEXT:    PointerToRawData:
+// CHECK-NEXT:    PointerToRelocations:
+// CHECK-NEXT:    PointerToLineNumbers:
+// CHECK-NEXT:    RelocationCount:
+// CHECK-NEXT:    LineNumberCount:
+// CHECK-NEXT:    Characteristics [
+// CHECK-NEXT:      IMAGE_SCN_ALIGN_4BYTES
+// CHECK-NEXT:      IMAGE_SCN_CNT_INITIALIZED_DATA
+// CHECK-NEXT:      IMAGE_SCN_MEM_READ
+// CHECK-NEXT:    ]




More information about the llvm-commits mailing list