OSDN Git Service

Add an entry for rodata constant merge sections to the default
authorEric Christopher <echristo@gmail.com>
Mon, 2 Jul 2018 00:16:39 +0000 (00:16 +0000)
committerEric Christopher <echristo@gmail.com>
Mon, 2 Jul 2018 00:16:39 +0000 (00:16 +0000)
section flags in the ELF assembler. This matches the defaults
given in the rest of MC.

Fixes PR37997 where we couldn't assemble our own assembly output
without warnings.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336072 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCParser/ELFAsmParser.cpp
test/MC/ELF/extra-section-flags.s

index 93513a2..67e3512 100644 (file)
@@ -486,6 +486,9 @@ static bool hasPrefix(StringRef SectionName, StringRef Prefix) {
 // defaults.
 static unsigned defaultSectionFlags(StringRef SectionName) {
 
+  if (hasPrefix(SectionName, ".rodata.cst"))
+    return ELF::SHF_ALLOC | ELF::SHF_MERGE;
+
   if (hasPrefix(SectionName, ".rodata.") || SectionName == ".rodata1")
     return ELF::SHF_ALLOC;
 
index c96516e..bde7e1a 100644 (file)
@@ -1,10 +1,12 @@
 # RUN: llvm-mc -triple x86_64-unknown-unknown -filetype=obj %s -o /dev/null 2>&1 | FileCheck %s
-       
+
 .section .rodata, "ax"
 # CHECK: warning: setting incorrect section attributes for .rodata
 nop
 
 .section .rodata, "a"
-# CHECK-NOT: warning:
 nop
+.section .rodata.cst4, "aM",@progbits,8
+nop
+# CHECK-NOT: warning: