[PATCH] D27451: Allow ELF section flags to be specified numerically

Prakhar Bahuguna via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 15 00:09:49 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL289785: Allow ELF section flags to be specified numerically (authored by prakhar).

Changed prior to commit:
  https://reviews.llvm.org/D27451?vs=80400&id=81538#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27451

Files:
  llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
  llvm/trunk/test/MC/ELF/section-numeric-flag.s


Index: llvm/trunk/test/MC/ELF/section-numeric-flag.s
===================================================================
--- llvm/trunk/test/MC/ELF/section-numeric-flag.s
+++ llvm/trunk/test/MC/ELF/section-numeric-flag.s
@@ -0,0 +1,37 @@
+// RUN: llvm-mc -filetype=obj %s -o - \
+// RUN: | llvm-readobj -s -t | FileCheck %s
+
+        .section .text,    "0x806", %progbits, unique, 0
+        .section .comment, "0x21"
+
+
+// CHECK:      Section {
+// CHECK:        Name: .text (1)
+// CHECK-NEXT:   Type: SHT_PROGBITS (0x1)
+// CHECK-NEXT:   Flags [ (0x6)
+// CHECK-NEXT:     SHF_ALLOC (0x2)
+// CHECK-NEXT:     SHF_EXECINSTR (0x4)
+// CHECK-NEXT:   ]
+// CHECK:        Size: 0
+// CHECK:      }
+
+// CHECK:      Section {
+// CHECK:        Name: .text (1)
+// CHECK-NEXT:   Type: SHT_PROGBITS (0x1)
+// CHECK-NEXT:   Flags [ (0x806)
+// CHECK-NEXT:     SHF_ALLOC (0x2)
+// CHECK-NEXT:     SHF_COMPRESSED (0x800)
+// CHECK-NEXT:     SHF_EXECINSTR (0x4)
+// CHECK-NEXT:   ]
+// CHECK:        Size: 0
+// CHECK:      }
+
+// CHECK:      Section {
+// CHECK:        Name: .comment (7)
+// CHECK-NEXT:   Type: SHT_PROGBITS (0x1)
+// CHECK-NEXT:   Flags [ (0x21)
+// CHECK-NEXT:     SHF_STRINGS (0x20)
+// CHECK-NEXT:     SHF_WRITE (0x1)
+// CHECK-NEXT:   ]
+// CHECK:        Size: 0
+// CHECK:      }
Index: llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
===================================================================
--- llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
+++ llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
@@ -264,6 +264,10 @@
 static unsigned parseSectionFlags(StringRef flagsStr, bool *UseLastGroup) {
   unsigned flags = 0;
 
+  // If a valid numerical value is set for the section flag, use it verbatim
+  if (!flagsStr.getAsInteger(0, flags))
+    return flags;
+
   for (char i : flagsStr) {
     switch (i) {
     case 'a':


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27451.81538.patch
Type: text/x-patch
Size: 1840 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161215/54210927/attachment.bin>


More information about the llvm-commits mailing list