[ARM] Uses "Sun Style" syntax for section switching
authorJian Cai <caij2003@gmail.com>
Fri, 25 Oct 2019 18:05:31 +0000 (11:05 -0700)
committerJian Cai <jiancai@google.com>
Fri, 25 Oct 2019 20:27:35 +0000 (13:27 -0700)
Summary:
Support "Sun Style" syntax for section switching ("#alloc,#write" etc).
https://bugs.llvm.org/show_bug.cgi?id=43759

Reviewers: peter.smith, eli.friedman, kristof.beyls, t.p.northover

Reviewed By: peter.smith

Subscribers: MaskRay, llozano, manojgupta, nickdesaulniers, kristof.beyls, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D69296

llvm/include/llvm/MC/MCAsmInfo.h
llvm/lib/Target/ARM/MCTargetDesc/ARMMCAsmInfo.cpp
llvm/test/MC/AsmParser/gas-compl-sun-elf.s [new file with mode: 0644]

index 3261c48..ce24ffb 100644 (file)
@@ -215,7 +215,7 @@ protected:
   const char *TPRel64Directive = nullptr;
 
   /// This is true if this target uses "Sun Style" syntax for section switching
-  /// ("#alloc,#write" etc) instead of the normal ELF syntax (,"a,w") in
+  /// ("#alloc,#write" etc) alongside the normal ELF syntax (,"a,w") in
   /// .section directives.  Defaults to false.
   bool SunStyleELFSectionSwitchSyntax = false;
 
index d30d15d..03505c0 100644 (file)
@@ -75,6 +75,10 @@ ARMELFMCAsmInfo::ARMELFMCAsmInfo(const Triple &TheTriple) {
   UseParensForSymbolVariant = true;
 
   UseIntegratedAssembler = true;
+
+  // The GNU assembler supports Sun style section switching for Arm targets, and
+  // it is used in projects like the Linux kernel.
+  SunStyleELFSectionSwitchSyntax = true;
 }
 
 void ARMELFMCAsmInfo::setUseIntegratedAssembler(bool Value) {
diff --git a/llvm/test/MC/AsmParser/gas-compl-sun-elf.s b/llvm/test/MC/AsmParser/gas-compl-sun-elf.s
new file mode 100644 (file)
index 0000000..7934109
--- /dev/null
@@ -0,0 +1,13 @@
+@ RUN: llvm-mc -filetype=obj -triple arm-linux-gnu %s -o - | llvm-readelf --sections | FileCheck %s
+
+@ CHECK: .f1              PROGBITS        00000000 000034 000000 00   A  0   0  1
+.section ".f1", #alloc
+
+@ CHECK: .f2              PROGBITS        00000000 000034 000000 00   W  0   0  1
+.section ".f2", #write
+
+@ CHECK: .f3              PROGBITS        00000000 000034 000000 00   A  0   0  1
+.section ".f3", "a"
+
+@ CHECK: .f4              PROGBITS        00000000 000034 000000 00   W  0   0  1
+.section ".f4", "w"