[PATCH] D34452: Implement the ".rdata" MIPS assembly directive.
John Baldwin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 21 07:54:06 PDT 2017
bsdjhb created this revision.
Herald added a subscriber: arichardson.
Rather than creating a separate ".rdata" section distinct from the
customary ".rodata" in ELF, ".rdata" switches to the ".rodata"
section.
https://reviews.llvm.org/D34452
Files:
lib/Target/Mips/AsmParser/MipsAsmParser.cpp
test/CodeGen/Mips/mips-rdata.s
Index: test/CodeGen/Mips/mips-rdata.s
===================================================================
--- /dev/null
+++ test/CodeGen/Mips/mips-rdata.s
@@ -0,0 +1,13 @@
+# Check that .rdata sections have proper name, flags, and section types.
+
+# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o - \
+# RUN: | llvm-readobj -s | FileCheck %s
+
+ .rdata
+ .word 0
+
+# CHECK: Name: .rodata
+# CHECK-NEXT: Type: SHT_PROGBITS
+# CHECK-NEXT: Flags [ (0x2)
+# CHECK-NEXT: SHF_ALLOC
+# CHECK-NEXT: ]
Index: lib/Target/Mips/AsmParser/MipsAsmParser.cpp
===================================================================
--- lib/Target/Mips/AsmParser/MipsAsmParser.cpp
+++ lib/Target/Mips/AsmParser/MipsAsmParser.cpp
@@ -321,6 +321,7 @@
bool parseDirectiveSet();
bool parseDirectiveOption();
bool parseInsnDirective();
+ bool parseRSectionDirective(StringRef Section);
bool parseSSectionDirective(StringRef Section, unsigned Type);
bool parseSetAtDirective();
@@ -6925,6 +6926,23 @@
return false;
}
+/// parseRSectionDirective
+/// ::= .rdata
+bool MipsAsmParser::parseRSectionDirective(StringRef Section) {
+ // 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, ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
+ getParser().getStreamer().SwitchSection(ELFSection);
+
+ getParser().Lex(); // Eat EndOfStatement token.
+ return false;
+}
+
/// parseSSectionDirective
/// ::= .sbss
/// ::= .sdata
@@ -7472,6 +7490,10 @@
parseInsnDirective();
return false;
}
+ if (IDVal == ".rdata") {
+ parseRSectionDirective(".rodata");
+ return false;
+ }
if (IDVal == ".sbss") {
parseSSectionDirective(IDVal, ELF::SHT_NOBITS);
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34452.103382.patch
Type: text/x-patch
Size: 1927 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170621/ea4aea82/attachment.bin>
More information about the llvm-commits
mailing list