diff options
| author | Simon Atanasyan <simon@atanasyan.com> | 2016-02-11 06:45:54 +0000 |
|---|---|---|
| committer | Simon Atanasyan <simon@atanasyan.com> | 2016-02-11 06:45:54 +0000 |
| commit | be186204323aa35996dce2d36b45a230ad44db38 (patch) | |
| tree | 4eff6200e00ebdfef4fb0b136ec7b67ae521b13f /llvm/lib/Target/Mips/AsmParser | |
| parent | 88db760e4b6dc781273f6ee6a263bf6e81691873 (diff) | |
| download | bcm5719-llvm-be186204323aa35996dce2d36b45a230ad44db38.tar.gz bcm5719-llvm-be186204323aa35996dce2d36b45a230ad44db38.zip | |
[MC][ELF] Handle MIPS specific .sdata and .sbss directives
MIPS specific .sdata and .sbss directives create corresponding sections
with proper initialized ELF flags including ELF::SHF_MIPS_GPREL.
Differential Revision: http://reviews.llvm.org/D17001
llvm-svn: 260498
Diffstat (limited to 'llvm/lib/Target/Mips/AsmParser')
| -rw-r--r-- | llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp index fb6a0712d9d..6b812d2f16f 100644 --- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -23,10 +23,12 @@ #include "llvm/MC/MCParser/MCAsmLexer.h" #include "llvm/MC/MCParser/MCParsedAsmOperand.h" #include "llvm/MC/MCParser/MCTargetAsmParser.h" +#include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/MCSymbol.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/ELF.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/TargetRegistry.h" @@ -266,6 +268,7 @@ class MipsAsmParser : public MCTargetAsmParser { bool parseDirectiveSet(); bool parseDirectiveOption(); bool parseInsnDirective(); + bool parseSSectionDirective(StringRef Section, unsigned Type); bool parseSetAtDirective(); bool parseSetNoAtDirective(); @@ -5734,6 +5737,24 @@ bool MipsAsmParser::parseInsnDirective() { return false; } +/// parseSSectionDirective +/// ::= .sbss +/// ::= .sdata +bool MipsAsmParser::parseSSectionDirective(StringRef Section, unsigned Type) { + // If this is not the end of the statement, report an error. + if (getLexer().isNot(AsmToken::EndOfStatement)) { + reportParseError("unexpected token, expected end of statement"); + return false; + } + + MCSection *ELFSection = getContext().getELFSection( + Section, Type, ELF::SHF_WRITE | ELF::SHF_ALLOC | ELF::SHF_MIPS_GPREL); + getParser().getStreamer().SwitchSection(ELFSection); + + getParser().Lex(); // Eat EndOfStatement token. + return false; +} + /// parseDirectiveModule /// ::= .module oddspreg /// ::= .module nooddspreg @@ -6224,6 +6245,11 @@ bool MipsAsmParser::ParseDirective(AsmToken DirectiveID) { if (IDVal == ".insn") return parseInsnDirective(); + if (IDVal == ".sbss") + return parseSSectionDirective(IDVal, ELF::SHT_NOBITS); + if (IDVal == ".sdata") + return parseSSectionDirective(IDVal, ELF::SHT_PROGBITS); + return true; } |

