[PATCH] D30229: [MC] Set defaults based on section names and support name suffixes
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 27 20:05:54 PST 2017
phosek updated this revision to Diff 89966.
phosek retitled this revision from "[MC] Mark sections whose names starts with .text as AX" to "[MC] Set defaults based on section names and support name suffixes".
phosek edited the summary of this revision.
Repository:
rL LLVM
https://reviews.llvm.org/D30229
Files:
lib/MC/MCParser/ELFAsmParser.cpp
test/MC/ELF/section.s
Index: test/MC/ELF/section.s
===================================================================
--- test/MC/ELF/section.s
+++ test/MC/ELF/section.s
@@ -216,3 +216,50 @@
// CHECK-NEXT: Size:
// CHECK-NEXT: Link: 22
// CHECK-NEXT: Info: 0
+
+.section .text.foo
+// CHECK: Section {
+// CHECK: Name: .text.foo
+// CHECK-NEXT: Type: SHT_PROGBITS
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: SHF_EXECINSTR
+// CHECK-NEXT: ]
+
+.section .bss
+// CHECK: Section {
+// CHECK: Name: .bss
+// CHECK-NEXT: Type: SHT_NOBITS
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: SHF_WRITE
+// CHECK-NEXT: ]
+
+.section .bss.foo
+// CHECK: Section {
+// CHECK: Name: .bss.foo
+// CHECK-NEXT: Type: SHT_NOBITS
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: SHF_WRITE
+// CHECK-NEXT: ]
+
+.section .tbss
+// CHECK: Section {
+// CHECK: Name: .tbss
+// CHECK-NEXT: Type: SHT_NOBITS
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: SHF_TLS
+// CHECK-NEXT: SHF_WRITE
+// CHECK-NEXT: ]
+
+.section .tbss.foo
+// CHECK: Section {
+// CHECK: Name: .tbss.foo
+// CHECK-NEXT: Type: SHT_NOBITS
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: SHF_TLS
+// CHECK-NEXT: SHF_WRITE
+// CHECK-NEXT: ]
Index: lib/MC/MCParser/ELFAsmParser.cpp
===================================================================
--- lib/MC/MCParser/ELFAsmParser.cpp
+++ lib/MC/MCParser/ELFAsmParser.cpp
@@ -484,10 +484,22 @@
// Set the defaults first.
if (SectionName == ".fini" || SectionName == ".init" ||
- SectionName == ".rodata")
+ SectionName == ".rodata" || SectionName.startswith(".rodata.") ||
+ SectionName == ".rodata1")
Flags |= ELF::SHF_ALLOC;
if (SectionName == ".fini" || SectionName == ".init")
Flags |= ELF::SHF_EXECINSTR;
+ if (SectionName == ".text" || SectionName.startswith(".text."))
+ Flags |= ELF::SHF_EXECINSTR | ELF::SHF_ALLOC;
+ if (SectionName == ".data" || SectionName.startswith(".data.") ||
+ SectionName == ".data1" ||
+ SectionName == ".bss" || SectionName.startswith(".bss.") ||
+ SectionName == ".init_array" || SectionName == ".fini_array" ||
+ SectionName == ".preinit_array")
+ Flags |= ELF::SHF_ALLOC | ELF::SHF_WRITE;
+ if (SectionName == ".tdata" || SectionName.startswith(".tdata.") ||
+ SectionName == ".tbss" || SectionName.startswith(".tbss."))
+ Flags |= ELF::SHF_TLS | ELF::SHF_WRITE | ELF::SHF_ALLOC;
if (getLexer().is(AsmToken::Comma)) {
Lex();
@@ -565,6 +577,10 @@
Type = ELF::SHT_FINI_ARRAY;
else if (SectionName == ".preinit_array")
Type = ELF::SHT_PREINIT_ARRAY;
+ else if (SectionName == ".bss" || SectionName.startswith(".bss."))
+ Type = ELF::SHT_NOBITS;
+ else if (SectionName == ".tbss" || SectionName.startswith(".tbss"))
+ Type = ELF::SHT_NOBITS;
} else {
if (TypeName == "init_array")
Type = ELF::SHT_INIT_ARRAY;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30229.89966.patch
Type: text/x-patch
Size: 3171 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170228/58e9b046/attachment.bin>
More information about the llvm-commits
mailing list