[llvm] r218189 - MC: Fix MCSectionCOFF::PrintSwitchToSection

David Majnemer david.majnemer at gmail.com
Sat Sep 20 13:40:50 PDT 2014


Author: majnemer
Date: Sat Sep 20 15:40:50 2014
New Revision: 218189

URL: http://llvm.org/viewvc/llvm-project?rev=218189&view=rev
Log:
MC: Fix MCSectionCOFF::PrintSwitchToSection

We had a few bugs:
- We were considering the GVKind instead of just looking at the section
  characteristics
- We would never print out 'y' when a section was meant to be unreadable
- We would never print out 's' when a section was meant to be shared
- We translated IMAGE_SCN_MEM_DISCARDABLE to 'n' when it should've meant
  IMAGE_SCN_LNK_REMOVE

Added:
    llvm/trunk/test/MC/COFF/section-passthru-flags.s
Modified:
    llvm/trunk/lib/MC/MCSectionCOFF.cpp

Modified: llvm/trunk/lib/MC/MCSectionCOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSectionCOFF.cpp?rev=218189&r1=218188&r2=218189&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCSectionCOFF.cpp (original)
+++ llvm/trunk/lib/MC/MCSectionCOFF.cpp Sat Sep 20 15:40:50 2014
@@ -47,18 +47,22 @@ void MCSectionCOFF::PrintSwitchToSection
   }
 
   OS << "\t.section\t" << getSectionName() << ",\"";
-  if (getKind().isText())
+  if (getCharacteristics() & COFF::IMAGE_SCN_MEM_EXECUTE)
     OS << 'x';
-  else if (getKind().isBSS())
-    OS << 'b';
-  if (getKind().isWriteable() && !getKind().isReadOnlyWithRel())
+  if (getCharacteristics() & COFF::IMAGE_SCN_MEM_WRITE)
     OS << 'w';
-  else
+  else if (getCharacteristics() & COFF::IMAGE_SCN_MEM_READ)
     OS << 'r';
-  if (getCharacteristics() & COFF::IMAGE_SCN_MEM_DISCARDABLE)
-    OS << 'n';
+  else
+    OS << 'y';
   if (getCharacteristics() & COFF::IMAGE_SCN_CNT_INITIALIZED_DATA)
     OS << 'd';
+  if (getCharacteristics() & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA)
+    OS << 'b';
+  if (getCharacteristics() & COFF::IMAGE_SCN_LNK_REMOVE)
+    OS << 'n';
+  if (getCharacteristics() & COFF::IMAGE_SCN_MEM_SHARED)
+    OS << 's';
   OS << '"';
 
   if (getCharacteristics() & COFF::IMAGE_SCN_LNK_COMDAT) {

Added: llvm/trunk/test/MC/COFF/section-passthru-flags.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/section-passthru-flags.s?rev=218189&view=auto
==============================================================================
--- llvm/trunk/test/MC/COFF/section-passthru-flags.s (added)
+++ llvm/trunk/test/MC/COFF/section-passthru-flags.s Sat Sep 20 15:40:50 2014
@@ -0,0 +1,7 @@
+// RUN: llvm-mc -triple i386-pc-win32 < %s | FileCheck %s
+.section .klaatu,"wn"
+// CHECK: .section .klaatu,"wn"
+.section .barada,"y"
+// CHECK: .section .barada,"y"
+.section .nikto,"wds"
+// CHECK: .section .nikto,"wds"





More information about the llvm-commits mailing list