Skip to content

Commit e542042

Browse files
author
git apple-llvm automerger
committed
Merge commit '700baa009dc6' from llvm.org/release/11.x into apple/stable/20200714
2 parents d48c7ba + 700baa0 commit e542042

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

llvm/lib/MC/MCParser/ELFAsmParser.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,10 +644,13 @@ bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) {
644644
!(SectionName == ".eh_frame" && Type == ELF::SHT_PROGBITS))
645645
Error(loc, "changed section type for " + SectionName + ", expected: 0x" +
646646
utohexstr(Section->getType()));
647-
if (Section->getFlags() != Flags)
647+
// Check that flags are used consistently. However, the GNU assembler permits
648+
// to leave out in subsequent uses of the same sections; for compatibility,
649+
// do likewise.
650+
if ((Flags || Size || !TypeName.empty()) && Section->getFlags() != Flags)
648651
Error(loc, "changed section flags for " + SectionName + ", expected: 0x" +
649652
utohexstr(Section->getFlags()));
650-
if (Section->getEntrySize() != Size)
653+
if ((Flags || Size || !TypeName.empty()) && Section->getEntrySize() != Size)
651654
Error(loc, "changed section entsize for " + SectionName +
652655
", expected: " + Twine(Section->getEntrySize()));
653656

llvm/test/MC/ELF/section-flags-changed.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ foo:
99
# CHECK: {{.*}}.s:[[# @LINE+1]]:1: error: changed section flags for .foo, expected: 0x6
1010
.pushsection .foo,"a",@progbits
1111

12+
# CHECK: {{.*}}.s:[[# @LINE+1]]:1: error: changed section flags for .foo, expected: 0x6
13+
.section .foo,"",@progbits
14+
1215
.pushsection .foo,"ax",@progbits
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# RUN: llvm-mc -triple=x86_64 %s -o - | FileCheck %s
2+
3+
# If section flags and other attributes are omitted, don't error.
4+
5+
# CHECK: .section .foo,"aM",@progbits,1
6+
7+
.section .foo,"aM",@progbits,1
8+
9+
.section .foo
10+
11+
.pushsection .foo

0 commit comments

Comments
 (0)