diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-07-12 20:42:34 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-07-12 20:42:34 +0000 |
commit | 4d5fe97c479ed3a2736755a3b821f5ff99c67cdc (patch) | |
tree | 181165805c00d4057f02809617636e5437dc3d49 /lib/MC/MCParser/AsmParser.cpp | |
parent | 19ad3b88f71fdc0fe0ec19e05bb37c3ef1a42b5b (diff) |
MC/AsmParser: Move .section parsing to Darwin specific parser.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108190 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCParser/AsmParser.cpp')
-rw-r--r-- | lib/MC/MCParser/AsmParser.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index 2d602bb785..29e4a9909b 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -82,6 +82,8 @@ public: &DarwinAsmParser::ParseDirectiveDumpOrLoad)); Parser.AddDirectiveHandler(this, ".load", MCAsmParser::DirectiveHandler( &DarwinAsmParser::ParseDirectiveDumpOrLoad)); + Parser.AddDirectiveHandler(this, ".section", MCAsmParser::DirectiveHandler( + &DarwinAsmParser::ParseDirectiveSection)); Parser.AddDirectiveHandler(this, ".secure_log_unique", MCAsmParser::DirectiveHandler( &DarwinAsmParser::ParseDirectiveSecureLogUnique)); @@ -230,6 +232,7 @@ public: bool ParseDirectiveDesc(StringRef, SMLoc); bool ParseDirectiveDumpOrLoad(StringRef, SMLoc); bool ParseDirectiveLsym(StringRef, SMLoc); + bool ParseDirectiveSection(); bool ParseDirectiveSecureLogReset(StringRef, SMLoc); bool ParseDirectiveSecureLogUnique(StringRef, SMLoc); bool ParseDirectiveSubsectionsViaSymbols(StringRef, SMLoc); @@ -947,10 +950,6 @@ bool AsmParser::ParseStatement() { // Otherwise, we have a normal instruction or directive. if (IDVal[0] == '.') { - // FIXME: This should be driven based on a hash lookup and callback. - if (IDVal == ".section") - return ParseDirectiveDarwinSection(); - // Assembler features if (IDVal == ".set") return ParseDirectiveSet(); @@ -1168,13 +1167,11 @@ bool AsmParser::ParseDirectiveSet() { /// ParseDirectiveSection: /// ::= .section identifier (',' identifier)* -/// FIXME: This should actually parse out the segment, section, attributes and -/// sizeof_stub fields. -bool AsmParser::ParseDirectiveDarwinSection() { +bool DarwinAsmParser::ParseDirectiveSection() { SMLoc Loc = getLexer().getLoc(); StringRef SectionName; - if (ParseIdentifier(SectionName)) + if (getParser().ParseIdentifier(SectionName)) return Error(Loc, "expected identifier after '.section' directive"); // Verify there is a following comma. @@ -1186,7 +1183,7 @@ bool AsmParser::ParseDirectiveDarwinSection() { // Add all the tokens until the end of the line, ParseSectionSpecifier will // handle this. - StringRef EOL = Lexer.LexUntilEndOfStatement(); + StringRef EOL = getLexer().LexUntilEndOfStatement(); SectionSpec.append(EOL.begin(), EOL.end()); Lex(); @@ -1197,16 +1194,16 @@ bool AsmParser::ParseDirectiveDarwinSection() { StringRef Segment, Section; unsigned TAA, StubSize; - std::string ErrorStr = + std::string ErrorStr = MCSectionMachO::ParseSectionSpecifier(SectionSpec, Segment, Section, TAA, StubSize); - + if (!ErrorStr.empty()) return Error(Loc, ErrorStr.c_str()); - + // FIXME: Arch specific. bool isText = Segment == "__TEXT"; // FIXME: Hack. - getStreamer().SwitchSection(Ctx.getMachOSection( + getStreamer().SwitchSection(getContext().getMachOSection( Segment, Section, TAA, StubSize, isText ? SectionKind::getText() : SectionKind::getDataRel())); |