diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -564,8 +564,24 @@ Kind = SectionKind::getExecuteOnly(); else if (Flags & ELF::SHF_EXECINSTR) Kind = SectionKind::getText(); - else + else if (~Flags & ELF::SHF_WRITE) Kind = SectionKind::getReadOnly(); + else if (Flags & ELF::SHF_TLS) + // FIXME: should we differentiate between SHT_PROGBITS and SHT_NOBITS? + Kind = SectionKind::getThreadData(); + else if (CachedName.startswith(".debug_")) + Kind = SectionKind::getMetadata(); + else + Kind = llvm::StringSwitch(CachedName) + .Case(".bss", SectionKind::getBSS()) + .Case(".data", SectionKind::getData()) + .Case(".data1", SectionKind::getMergeable1ByteCString()) + .Case(".data.rel.ro", SectionKind::getReadOnlyWithRel()) + .Case(".rodata", SectionKind::getReadOnly()) + .Case(".rodata1", SectionKind::getReadOnly()) + .Case(".tbss", SectionKind::getThreadBSS()) + .Case(".tdata", SectionKind::getThreadData()) + .Default(SectionKind::getText()); MCSectionELF *Result = createELFSectionImpl(CachedName, Type, Flags, Kind, EntrySize, GroupSym,