diff options
Diffstat (limited to 'lib/MC/MCParser/ELFAsmParser.cpp')
-rw-r--r-- | lib/MC/MCParser/ELFAsmParser.cpp | 54 |
1 files changed, 13 insertions, 41 deletions
diff --git a/lib/MC/MCParser/ELFAsmParser.cpp b/lib/MC/MCParser/ELFAsmParser.cpp index e302004..7a120a1 100644 --- a/lib/MC/MCParser/ELFAsmParser.cpp +++ b/lib/MC/MCParser/ELFAsmParser.cpp @@ -199,8 +199,7 @@ bool ELFAsmParser::ParseSectionSwitch(StringRef Section, unsigned Type, return true; } - getStreamer().SwitchSection(getContext().getELFSection( - Section, Type, Flags, Kind), + getStreamer().SwitchSection(getContext().getELFSection(Section, Type, Flags), Subsection); return false; @@ -269,40 +268,6 @@ bool ELFAsmParser::ParseSectionName(StringRef &SectionName) { return false; } -static SectionKind computeSectionKind(unsigned Flags, unsigned ElemSize) { - if (Flags & ELF::SHF_EXECINSTR) - return SectionKind::getText(); - if (Flags & ELF::SHF_TLS) - return SectionKind::getThreadData(); - if (Flags & ELF::SHF_MERGE) { - if (Flags & ELF::SHF_STRINGS) { - switch (ElemSize) { - default: - break; - case 1: - return SectionKind::getMergeable1ByteCString(); - case 2: - return SectionKind::getMergeable2ByteCString(); - case 4: - return SectionKind::getMergeable4ByteCString(); - } - } else { - switch (ElemSize) { - default: - break; - case 4: - return SectionKind::getMergeableConst4(); - case 8: - return SectionKind::getMergeableConst8(); - case 16: - return SectionKind::getMergeableConst16(); - } - } - } - - return SectionKind::getDataRel(); -} - static unsigned parseSectionFlags(StringRef flagsStr, bool *UseLastGroup) { unsigned flags = 0; @@ -413,6 +378,8 @@ bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) { unsigned Flags = 0; const MCExpr *Subsection = nullptr; bool UseLastGroup = false; + StringRef UniqueStr; + bool Unique = false; // Set the defaults first. if (SectionName == ".fini" || SectionName == ".init" || @@ -497,6 +464,14 @@ bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) { return TokError("Linkage must be 'comdat'"); } } + if (getLexer().is(AsmToken::Comma)) { + Lex(); + if (getParser().parseIdentifier(UniqueStr)) + return TokError("expected identifier in directive"); + if (UniqueStr != "unique") + return TokError("expected 'unique'"); + Unique = true; + } } } @@ -544,9 +519,8 @@ EndStmt: } } - SectionKind Kind = computeSectionKind(Flags, Size); const MCSection *ELFSection = getContext().getELFSection( - SectionName, Type, Flags, Kind, Size, GroupName); + SectionName, Type, Flags, Size, GroupName, Unique); getStreamer().SwitchSection(ELFSection, Subsection); if (getContext().getGenDwarfForAssembly()) { @@ -697,9 +671,7 @@ bool ELFAsmParser::ParseDirectiveVersion(StringRef, SMLoc) { Lex(); - const MCSection *Note = - getContext().getELFSection(".note", ELF::SHT_NOTE, 0, - SectionKind::getReadOnly()); + const MCSection *Note = getContext().getELFSection(".note", ELF::SHT_NOTE, 0); getStreamer().PushSection(); getStreamer().SwitchSection(Note); |