diff options
author | Petr Hosek <phosek@chromium.org> | 2017-04-04 23:32:45 +0000 |
---|---|---|
committer | Petr Hosek <phosek@chromium.org> | 2017-04-04 23:32:45 +0000 |
commit | 880cfd45fcc0b9417a7c8d22c45b38dd1fe23929 (patch) | |
tree | 48380a6f6e41c51c44c2dbc4c9af36e098e11dcd /llvm/lib/MC/MCParser/ELFAsmParser.cpp | |
parent | d3c03a5ddd9523386ef766a397483d09a60f7156 (diff) | |
download | bcm5719-llvm-880cfd45fcc0b9417a7c8d22c45b38dd1fe23929.tar.gz bcm5719-llvm-880cfd45fcc0b9417a7c8d22c45b38dd1fe23929.zip |
[MC] Set defaults based on section names and support name suffixes
Set correct default flags and section type based on its name for .text,
.data, .bss, .init_array, .fini_array, .preinit_array, .tdata, and .tbss
and support section name suffixes for .data.*, .rodata.*, .text.*,
.bss.*, .tdata.* and .tbss.* which matches the behavior of GAS.
Fixes PR31888.
Differential Revision: https://reviews.llvm.org/D30229
llvm-svn: 299484
Diffstat (limited to 'llvm/lib/MC/MCParser/ELFAsmParser.cpp')
-rw-r--r-- | llvm/lib/MC/MCParser/ELFAsmParser.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp index ed911cbc756..401011a027f 100644 --- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp +++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp @@ -493,11 +493,20 @@ bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) { int64_t UniqueID = ~0; // Set the defaults first. - if (SectionName == ".fini" || SectionName == ".init" || - SectionName == ".rodata") + if (hasPrefix(SectionName, ".rodata.") || SectionName == ".rodata1") Flags |= ELF::SHF_ALLOC; - if (SectionName == ".fini" || SectionName == ".init") - Flags |= ELF::SHF_EXECINSTR; + if (SectionName == ".fini" || SectionName == ".init" || + hasPrefix(SectionName, ".text.")) + Flags |= ELF::SHF_ALLOC | ELF::SHF_EXECINSTR; + if (hasPrefix(SectionName, ".data.") || SectionName == ".data1" || + hasPrefix(SectionName, ".bss.") || + hasPrefix(SectionName, ".init_array.") || + hasPrefix(SectionName, ".fini_array.") || + hasPrefix(SectionName, ".preinit_array.")) + Flags |= ELF::SHF_ALLOC | ELF::SHF_WRITE; + if (hasPrefix(SectionName, ".tdata.") || + hasPrefix(SectionName, ".tbss.")) + Flags |= ELF::SHF_ALLOC | ELF::SHF_WRITE | ELF::SHF_TLS; if (getLexer().is(AsmToken::Comma)) { Lex(); @@ -575,9 +584,9 @@ EndStmt: Type = ELF::SHT_NOBITS; else if (hasPrefix(SectionName, ".tbss.")) Type = ELF::SHT_NOBITS; - else if (SectionName == ".fini_array") + else if (hasPrefix(SectionName, ".fini_array.")) Type = ELF::SHT_FINI_ARRAY; - else if (SectionName == ".preinit_array") + else if (hasPrefix(SectionName, ".preinit_array.")) Type = ELF::SHT_PREINIT_ARRAY; } else { if (TypeName == "init_array") |