[llvm-commits] [PATCH] ELFAsmParser section directives
Eli Friedman
eli.friedman at gmail.com
Tue Jul 20 13:37:09 PDT 2010
On Tue, Jul 20, 2010 at 12:09 PM, Matt Fleming <matt at console-pimps.org> wrote:
> The following patch adds various directives that specify the start of a
> section. OK to commit along with tests in a new test/MC/AsmParser/ELF
> directory?
>
> Index: lib/MC/MCParser/ELFAsmParser.cpp
> ===================================================================
> --- lib/MC/MCParser/ELFAsmParser.cpp (revision 108749)
> +++ lib/MC/MCParser/ELFAsmParser.cpp (working copy)
> @@ -42,6 +42,14 @@
> AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSize>(".size");
> AddDirectiveHandler<&ELFAsmParser::ParseDirectiveLEB128>(".sleb128");
> AddDirectiveHandler<&ELFAsmParser::ParseDirectiveLEB128>(".uleb128");
> + AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveBSS>(".bss");
> + AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveRoData>(".rodata");
> + AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveTData>(".tdata");
> + AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveTBSS>(".tbss");
> + AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveDataRel>(".data.rel");
> + AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveDataRelRo>(".data.rel.ro");
> + AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveDataRelRoLocal>(".data.rel.ro.local");
> + AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveEhFrame>(".eh_frame");
> }
Should be grouped with other ParseSection*
> bool ParseSectionDirectiveData(StringRef, SMLoc) {
> @@ -57,6 +65,52 @@
> bool ParseDirectiveLEB128(StringRef, SMLoc);
> bool ParseDirectiveSection(StringRef, SMLoc);
> bool ParseDirectiveSize(StringRef, SMLoc);
> + bool ParseSectionDirectiveBSS(StringRef, SMLoc) {
> + return ParseSectionSwitch(".bss", MCSectionELF::SHT_NOBITS,
> + MCSectionELF::SHF_WRITE |
> + MCSectionELF::SHF_ALLOC, SectionKind::getBSS());
> + }
> + bool ParseSectionDirectiveRoData(StringRef, SMLoc) {
> + return ParseSectionSwitch(".rodata", MCSectionELF::SHT_PROGBITS,
> + MCSectionELF::SHF_ALLOC,
> + SectionKind::getReadOnly());
> + }
> + bool ParseSectionDirectiveTData(StringRef, SMLoc) {
> + return ParseSectionSwitch(".tdata", MCSectionELF::SHT_PROGBITS,
> + MCSectionELF::SHF_ALLOC |
> + MCSectionELF::SHF_TLS | MCSectionELF::SHF_WRITE,
> + SectionKind::getThreadData());
> + }
> + bool ParseSectionDirectiveTBSS(StringRef, SMLoc) {
> + return ParseSectionSwitch(".tbss", MCSectionELF::SHT_NOBITS,
> + MCSectionELF::SHF_ALLOC |
> + MCSectionELF::SHF_TLS | MCSectionELF::SHF_WRITE,
> + SectionKind::getThreadBSS());
> + }
> + bool ParseSectionDirectiveDataRel(StringRef, SMLoc) {
> + return ParseSectionSwitch(".data.rel", MCSectionELF::SHT_PROGBITS,
> + MCSectionELF::SHF_ALLOC |
> + MCSectionELF::SHF_WRITE,
> + SectionKind::getDataRel());
> + }
> + bool ParseSectionDirectiveDataRelRo(StringRef, SMLoc) {
> + return ParseSectionSwitch(".data.rel.ro", MCSectionELF::SHT_PROGBITS,
> + MCSectionELF::SHF_ALLOC |
> + MCSectionELF::SHF_WRITE,
> + SectionKind::getReadOnlyWithRel());
> + }
> + bool ParseSectionDirectiveDataRelRoLocal(StringRef, SMLoc) {
> + return ParseSectionSwitch(".data.rel.ro.local", MCSectionELF::SHT_PROGBITS,
> + MCSectionELF::SHF_ALLOC |
> + MCSectionELF::SHF_WRITE,
> + SectionKind::getReadOnlyWithRelLocal());
> + }
> + bool ParseSectionDirectiveEhFrame(StringRef, SMLoc) {
> + return ParseSectionSwitch(".eh_frame", MCSectionELF::SHT_PROGBITS,
> + MCSectionELF::SHF_ALLOC |
> + MCSectionELF::SHF_WRITE,
> + SectionKind::getDataRel());
> + }
> };
Should be grouped with other ParsxeSection*
Otherwise, looks fine.
-Eli
More information about the llvm-commits
mailing list