diff options
Diffstat (limited to 'lib/MC')
-rw-r--r-- | lib/MC/MCContext.cpp | 3 | ||||
-rw-r--r-- | lib/MC/MCELFStreamer.cpp | 8 | ||||
-rw-r--r-- | lib/MC/MCParser/ELFAsmParser.cpp | 37 | ||||
-rw-r--r-- | lib/MC/MCSectionELF.cpp | 16 |
4 files changed, 34 insertions, 30 deletions
diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp index 839c08d8a2..018f00c08f 100644 --- a/lib/MC/MCContext.cpp +++ b/lib/MC/MCContext.cpp @@ -18,6 +18,7 @@ #include "llvm/Target/TargetAsmInfo.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/Twine.h" +#include "llvm/Support/ELF.h" using namespace llvm; typedef StringMap<const MCSectionMachO*> MachOUniqueMapTy; @@ -211,7 +212,7 @@ getELFSection(StringRef Section, unsigned Type, unsigned Flags, const MCSectionELF *MCContext::CreateELFGroupSection() { MCSectionELF *Result = - new (*this) MCSectionELF(".group", MCSectionELF::SHT_GROUP, 0, + new (*this) MCSectionELF(".group", ELF::SHT_GROUP, 0, SectionKind::getReadOnly(), 4, NULL); return Result; } diff --git a/lib/MC/MCELFStreamer.cpp b/lib/MC/MCELFStreamer.cpp index 2369821204..1c89b5655e 100644 --- a/lib/MC/MCELFStreamer.cpp +++ b/lib/MC/MCELFStreamer.cpp @@ -155,19 +155,19 @@ private: } void SetSectionData() { - SetSection(".data", MCSectionELF::SHT_PROGBITS, + SetSection(".data", ELF::SHT_PROGBITS, MCSectionELF::SHF_WRITE |MCSectionELF::SHF_ALLOC, SectionKind::getDataRel()); EmitCodeAlignment(4, 0); } void SetSectionText() { - SetSection(".text", MCSectionELF::SHT_PROGBITS, + SetSection(".text", ELF::SHT_PROGBITS, MCSectionELF::SHF_EXECINSTR | MCSectionELF::SHF_ALLOC, SectionKind::getText()); EmitCodeAlignment(4, 0); } void SetSectionBss() { - SetSection(".bss", MCSectionELF::SHT_NOBITS, + SetSection(".bss", ELF::SHT_NOBITS, MCSectionELF::SHF_WRITE | MCSectionELF::SHF_ALLOC, SectionKind::getBSS()); EmitCodeAlignment(4, 0); @@ -346,7 +346,7 @@ void MCELFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, if (GetBinding(SD) == ELF_STB_Local) { const MCSection *Section = getAssembler().getContext().getELFSection(".bss", - MCSectionELF::SHT_NOBITS, + ELF::SHT_NOBITS, MCSectionELF::SHF_WRITE | MCSectionELF::SHF_ALLOC, SectionKind::getBSS()); diff --git a/lib/MC/MCParser/ELFAsmParser.cpp b/lib/MC/MCParser/ELFAsmParser.cpp index 0456b4bac4..a3bd1d7dfb 100644 --- a/lib/MC/MCParser/ELFAsmParser.cpp +++ b/lib/MC/MCParser/ELFAsmParser.cpp @@ -16,6 +16,7 @@ #include "llvm/MC/MCParser/MCAsmLexer.h" #include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCStreamer.h" +#include "llvm/Support/ELF.h" using namespace llvm; namespace { @@ -59,57 +60,57 @@ public: // FIXME: Part of this logic is duplicated in the MCELFStreamer. What is // the best way for us to get access to it? bool ParseSectionDirectiveData(StringRef, SMLoc) { - return ParseSectionSwitch(".data", MCSectionELF::SHT_PROGBITS, + return ParseSectionSwitch(".data", ELF::SHT_PROGBITS, MCSectionELF::SHF_WRITE |MCSectionELF::SHF_ALLOC, SectionKind::getDataRel()); } bool ParseSectionDirectiveText(StringRef, SMLoc) { - return ParseSectionSwitch(".text", MCSectionELF::SHT_PROGBITS, + return ParseSectionSwitch(".text", ELF::SHT_PROGBITS, MCSectionELF::SHF_EXECINSTR | MCSectionELF::SHF_ALLOC, SectionKind::getText()); } bool ParseSectionDirectiveBSS(StringRef, SMLoc) { - return ParseSectionSwitch(".bss", MCSectionELF::SHT_NOBITS, + return ParseSectionSwitch(".bss", ELF::SHT_NOBITS, MCSectionELF::SHF_WRITE | MCSectionELF::SHF_ALLOC, SectionKind::getBSS()); } bool ParseSectionDirectiveRoData(StringRef, SMLoc) { - return ParseSectionSwitch(".rodata", MCSectionELF::SHT_PROGBITS, + return ParseSectionSwitch(".rodata", ELF::SHT_PROGBITS, MCSectionELF::SHF_ALLOC, SectionKind::getReadOnly()); } bool ParseSectionDirectiveTData(StringRef, SMLoc) { - return ParseSectionSwitch(".tdata", MCSectionELF::SHT_PROGBITS, + return ParseSectionSwitch(".tdata", ELF::SHT_PROGBITS, MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_TLS | MCSectionELF::SHF_WRITE, SectionKind::getThreadData()); } bool ParseSectionDirectiveTBSS(StringRef, SMLoc) { - return ParseSectionSwitch(".tbss", MCSectionELF::SHT_NOBITS, + return ParseSectionSwitch(".tbss", ELF::SHT_NOBITS, MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_TLS | MCSectionELF::SHF_WRITE, SectionKind::getThreadBSS()); } bool ParseSectionDirectiveDataRel(StringRef, SMLoc) { - return ParseSectionSwitch(".data.rel", MCSectionELF::SHT_PROGBITS, + return ParseSectionSwitch(".data.rel", ELF::SHT_PROGBITS, MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE, SectionKind::getDataRel()); } bool ParseSectionDirectiveDataRelRo(StringRef, SMLoc) { - return ParseSectionSwitch(".data.rel.ro", MCSectionELF::SHT_PROGBITS, + return ParseSectionSwitch(".data.rel.ro", ELF::SHT_PROGBITS, MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE, SectionKind::getReadOnlyWithRel()); } bool ParseSectionDirectiveDataRelRoLocal(StringRef, SMLoc) { - return ParseSectionSwitch(".data.rel.ro.local", MCSectionELF::SHT_PROGBITS, + return ParseSectionSwitch(".data.rel.ro.local", ELF::SHT_PROGBITS, MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE, SectionKind::getReadOnlyWithRelLocal()); } bool ParseSectionDirectiveEhFrame(StringRef, SMLoc) { - return ParseSectionSwitch(".eh_frame", MCSectionELF::SHT_PROGBITS, + return ParseSectionSwitch(".eh_frame", ELF::SHT_PROGBITS, MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE, SectionKind::getDataRel()); @@ -322,21 +323,21 @@ bool ELFAsmParser::ParseDirectiveSection(StringRef, SMLoc) { if (getLexer().isNot(AsmToken::EndOfStatement)) return TokError("unexpected token in directive"); - unsigned Type = MCSectionELF::SHT_PROGBITS; + unsigned Type = ELF::SHT_PROGBITS; if (!TypeName.empty()) { if (TypeName == "init_array") - Type = MCSectionELF::SHT_INIT_ARRAY; + Type = ELF::SHT_INIT_ARRAY; else if (TypeName == "fini_array") - Type = MCSectionELF::SHT_FINI_ARRAY; + Type = ELF::SHT_FINI_ARRAY; else if (TypeName == "preinit_array") - Type = MCSectionELF::SHT_PREINIT_ARRAY; + Type = ELF::SHT_PREINIT_ARRAY; else if (TypeName == "nobits") - Type = MCSectionELF::SHT_NOBITS; + Type = ELF::SHT_NOBITS; else if (TypeName == "progbits") - Type = MCSectionELF::SHT_PROGBITS; + Type = ELF::SHT_PROGBITS; else if (TypeName == "note") - Type = MCSectionELF::SHT_NOTE; + Type = ELF::SHT_NOTE; else return TokError("unknown section type"); } @@ -415,7 +416,7 @@ bool ELFAsmParser::ParseDirectiveIdent(StringRef, SMLoc) { const MCSection *OldSection = getStreamer().getCurrentSection(); const MCSection *Comment = - getContext().getELFSection(".comment", MCSectionELF::SHT_PROGBITS, + getContext().getELFSection(".comment", ELF::SHT_PROGBITS, MCSectionELF::SHF_MERGE | MCSectionELF::SHF_STRINGS, SectionKind::getReadOnly(), diff --git a/lib/MC/MCSectionELF.cpp b/lib/MC/MCSectionELF.cpp index a53489790d..4a44f5a906 100644 --- a/lib/MC/MCSectionELF.cpp +++ b/lib/MC/MCSectionELF.cpp @@ -11,7 +11,9 @@ #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCSymbol.h" +#include "llvm/Support/ELF.h" #include "llvm/Support/raw_ostream.h" + using namespace llvm; MCSectionELF::~MCSectionELF() {} // anchor. @@ -84,17 +86,17 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI, else OS << '@'; - if (Type == MCSectionELF::SHT_INIT_ARRAY) + if (Type == ELF::SHT_INIT_ARRAY) OS << "init_array"; - else if (Type == MCSectionELF::SHT_FINI_ARRAY) + else if (Type == ELF::SHT_FINI_ARRAY) OS << "fini_array"; - else if (Type == MCSectionELF::SHT_PREINIT_ARRAY) + else if (Type == ELF::SHT_PREINIT_ARRAY) OS << "preinit_array"; - else if (Type == MCSectionELF::SHT_NOBITS) + else if (Type == ELF::SHT_NOBITS) OS << "nobits"; - else if (Type == MCSectionELF::SHT_NOTE) + else if (Type == ELF::SHT_NOTE) OS << "note"; - else if (Type == MCSectionELF::SHT_PROGBITS) + else if (Type == ELF::SHT_PROGBITS) OS << "progbits"; if (EntrySize) { @@ -110,7 +112,7 @@ bool MCSectionELF::UseCodeAlign() const { } bool MCSectionELF::isVirtualSection() const { - return getType() == MCSectionELF::SHT_NOBITS; + return getType() == ELF::SHT_NOBITS; } // HasCommonSymbols - True if this section holds common symbols, this is |