[PATCH] D27986: Print numeric section flag for OS/processor specific bits

Prakhar Bahuguna via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 26 01:39:25 PST 2017


prakhar updated this revision to Diff 85873.
prakhar added a comment.

Style and formatting fix


https://reviews.llvm.org/D27986

Files:
  lib/MC/MCSectionELF.cpp
  test/CodeGen/ARM/execute-only-section.ll


Index: test/CodeGen/ARM/execute-only-section.ll
===================================================================
--- test/CodeGen/ARM/execute-only-section.ll
+++ test/CodeGen/ARM/execute-only-section.ll
@@ -2,7 +2,7 @@
 ; RUN: llc < %s -mtriple=thumbv8m.base -arm-execute-only %s -o - | FileCheck %s
 ; RUN: llc < %s -mtriple=thumbv8m.main -arm-execute-only %s -o - | FileCheck %s
 
-; CHECK:     .section .text,"axy",%progbits,unique,0
+; CHECK:     .section .text,"0x20000006",%progbits,unique,0
 ; CHECK-NOT: .section
 ; CHECK-NOT: .text
 ; CHECK:     .globl test_SectionForGlobal
@@ -12,7 +12,7 @@
   ret void
 }
 
-; CHECK:     .section .test,"axy",%progbits
+; CHECK:     .section .test,"0x20000006",%progbits
 ; CHECK-NOT: .section
 ; CHECK-NOT: .text
 ; CHECK:     .globl test_ExplicitSectionForGlobal
Index: lib/MC/MCSectionELF.cpp
===================================================================
--- lib/MC/MCSectionELF.cpp
+++ lib/MC/MCSectionELF.cpp
@@ -14,6 +14,7 @@
 #include "llvm/MC/MCSymbol.h"
 #include "llvm/Support/ELF.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/Format.h"
 
 using namespace llvm;
 
@@ -88,30 +89,35 @@
   }
 
   OS << ",\"";
-  if (Flags & ELF::SHF_ALLOC)
-    OS << 'a';
-  if (Flags & ELF::SHF_EXCLUDE)
-    OS << 'e';
-  if (Flags & ELF::SHF_EXECINSTR)
-    OS << 'x';
-  if (Flags & ELF::SHF_GROUP)
-    OS << 'G';
-  if (Flags & ELF::SHF_WRITE)
-    OS << 'w';
-  if (Flags & ELF::SHF_MERGE)
-    OS << 'M';
-  if (Flags & ELF::SHF_STRINGS)
-    OS << 'S';
-  if (Flags & ELF::SHF_TLS)
-    OS << 'T';
-
-  // If there are target-specific flags, print them.
-  if (Flags & ELF::XCORE_SHF_CP_SECTION)
-    OS << 'c';
-  if (Flags & ELF::XCORE_SHF_DP_SECTION)
-    OS << 'd';
-  if (Flags & ELF::SHF_ARM_PURECODE)
-    OS << 'y';
+
+  // If the flag has OS or processor-specific bits set, print the whole numeric
+  // flag, otherwise use the symbolic representation
+  if (Flags & (ELF::SHF_MASKOS | ELF::SHF_MASKPROC)) {
+    OS << format_hex(Flags, 0);
+  } else {
+    if (Flags & ELF::SHF_ALLOC)
+      OS << 'a';
+    if (Flags & ELF::SHF_EXCLUDE)
+      OS << 'e';
+    if (Flags & ELF::SHF_EXECINSTR)
+      OS << 'x';
+    if (Flags & ELF::SHF_GROUP)
+      OS << 'G';
+    if (Flags & ELF::SHF_WRITE)
+      OS << 'w';
+    if (Flags & ELF::SHF_MERGE)
+      OS << 'M';
+    if (Flags & ELF::SHF_STRINGS)
+      OS << 'S';
+    if (Flags & ELF::SHF_TLS)
+      OS << 'T';
+
+    // If there are target-specific flags, print them.
+    if (Flags & ELF::XCORE_SHF_CP_SECTION)
+      OS << 'c';
+    if (Flags & ELF::XCORE_SHF_DP_SECTION)
+      OS << 'd';
+  }
 
   OS << '"';
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27986.85873.patch
Type: text/x-patch
Size: 2656 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170126/93812077/attachment.bin>


More information about the llvm-commits mailing list