diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2010-09-15 21:48:40 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2010-09-15 21:48:40 +0000 |
commit | f667d929ce17f686fcd667045f5943890401dda9 (patch) | |
tree | 6195d964f715f45fbca4d1bbe835124fc2b9c7b5 /llvm/lib/MC/MCParser/ELFAsmParser.cpp | |
parent | 44857a38fa5d04d04bca44fdfc0026ae33a014f7 (diff) | |
download | bcm5719-llvm-f667d929ce17f686fcd667045f5943890401dda9.tar.gz bcm5719-llvm-f667d929ce17f686fcd667045f5943890401dda9.zip |
Add a InitSections method to the streamer interface.
The ELF implementation now creates text, data and bss to match the gnu as
behavior.
The text streamer still has the old MachO specific behavior since
the testsuite checks that it will error when a directive is given
before a setting the current section for example.
A nice benefit is that -n is not required anymore when producing
ELF files.
llvm-svn: 114027
Diffstat (limited to 'llvm/lib/MC/MCParser/ELFAsmParser.cpp')
-rw-r--r-- | llvm/lib/MC/MCParser/ELFAsmParser.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp index 38288d78b01..ddf988faa64 100644 --- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp +++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp @@ -51,20 +51,28 @@ public: AddDirectiveHandler<&ELFAsmParser::ParseDirectivePrevious>(".previous"); } + // 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, + bool ret = ParseSectionSwitch(".data", MCSectionELF::SHT_PROGBITS, MCSectionELF::SHF_WRITE |MCSectionELF::SHF_ALLOC, SectionKind::getDataRel()); + getStreamer().EmitCodeAlignment(4, 0); + return ret; } bool ParseSectionDirectiveText(StringRef, SMLoc) { - return ParseSectionSwitch(".text", MCSectionELF::SHT_PROGBITS, + bool ret = ParseSectionSwitch(".text", MCSectionELF::SHT_PROGBITS, MCSectionELF::SHF_EXECINSTR | MCSectionELF::SHF_ALLOC, SectionKind::getText()); + getStreamer().EmitCodeAlignment(4, 0); + return ret; } bool ParseSectionDirectiveBSS(StringRef, SMLoc) { - return ParseSectionSwitch(".bss", MCSectionELF::SHT_NOBITS, + bool ret = ParseSectionSwitch(".bss", MCSectionELF::SHT_NOBITS, MCSectionELF::SHF_WRITE | MCSectionELF::SHF_ALLOC, SectionKind::getBSS()); + getStreamer().EmitCodeAlignment(4, 0); + return ret; } bool ParseSectionDirectiveRoData(StringRef, SMLoc) { return ParseSectionSwitch(".rodata", MCSectionELF::SHT_PROGBITS, |