diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp --- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp +++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp @@ -676,14 +676,14 @@ getContext().getELFSection(SectionName, Type, Flags, Size, GroupName, IsComdat, UniqueID, LinkedToSym); getStreamer().SwitchSection(Section, Subsection); - if (Section->getType() != Type && + // Check that flags are used consistently. However, the GNU assembler permits + // to leave out in subsequent uses of the same sections; for compatibility, + // do likewise. + if (!TypeName.empty() && Section->getType() != Type && !allowSectionTypeMismatch(getContext().getTargetTriple(), SectionName, Type)) Error(loc, "changed section type for " + SectionName + ", expected: 0x" + utohexstr(Section->getType())); - // Check that flags are used consistently. However, the GNU assembler permits - // to leave out in subsequent uses of the same sections; for compatibility, - // do likewise. if ((extraFlags || Size || !TypeName.empty()) && Section->getFlags() != Flags) Error(loc, "changed section flags for " + SectionName + ", expected: 0x" + utohexstr(Section->getFlags())); diff --git a/llvm/test/MC/ELF/section-omitted-attributes.s b/llvm/test/MC/ELF/section-omitted-attributes.s --- a/llvm/test/MC/ELF/section-omitted-attributes.s +++ b/llvm/test/MC/ELF/section-omitted-attributes.s @@ -4,6 +4,7 @@ # CHECK: .section .foo,"aM",@progbits,1 # CHECK: .section .rodata.cst8,"aM",@progbits,8 +# CHECK: .section .lds_bss,"w",@nobits .section .foo,"aM",@progbits,1 @@ -15,3 +16,7 @@ .section .rodata.cst8,"aM",@progbits,8 .section .rodata.cst8 + +# Likewise for Type changes +.section .lds_bss,"w",@nobits +.section .lds_bss