Add an entry for rodata constant merge sections to the default

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.

llvm-svn: 336072
This commit is contained in:
Eric Christopher 2018-07-02 00:16:39 +00:00
parent df99cdb95b
commit 53054141a7
2 changed files with 7 additions and 2 deletions

View 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;

View 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: