aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2012-08-08 06:30:30 +0000
committerBill Wendling <isanbard@gmail.com>2012-08-08 06:30:30 +0000
commitef920552d4fb0959097f1c165cfc81c69db19934 (patch)
treea1f589492e274e09eb1aa6dcdac1b0fb4a27eb86 /test
parentd43b5c97cff06d7840b974ca84fa0639d2567968 (diff)
downloadexternal_llvm-ef920552d4fb0959097f1c165cfc81c69db19934.zip
external_llvm-ef920552d4fb0959097f1c165cfc81c69db19934.tar.gz
external_llvm-ef920552d4fb0959097f1c165cfc81c69db19934.tar.bz2
Add `.pushsection', `.popsection', and `.previous' directives to Darwin ASM.
There are situations where inline ASM may want to change the section -- for instance, to create a variable in the .data section. However, it cannot do this without (potentially) restoring to the wrong section. E.g.: asm volatile (".section __DATA, __data\n\t" ".globl _fnord\n\t" "_fnord: .quad 1f\n\t" ".text\n\t" "1:" :::); This may be wrong if this is inlined into a function that has a "section" attribute. The user should use `.pushsection' and `.popsection' here instead. The addition of `.previous' is added for completeness. <rdar://problem/12048387> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161477 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/MC/MachO/previous.s13
-rw-r--r--test/MC/MachO/pushsection.s16
2 files changed, 29 insertions, 0 deletions
diff --git a/test/MC/MachO/previous.s b/test/MC/MachO/previous.s
new file mode 100644
index 0000000..41077cd
--- /dev/null
+++ b/test/MC/MachO/previous.s
@@ -0,0 +1,13 @@
+// RUN: llvm-mc -triple i386-apple-darwin9 %s -o - | FileCheck %s
+
+.text
+// CHECK: .section __TEXT,__text
+
+.data
+// CHECK: .section __DATA,__data
+
+.previous
+// CHECK: .section __TEXT,__text
+
+.previous
+// CHECK: .section __DATA,__data
diff --git a/test/MC/MachO/pushsection.s b/test/MC/MachO/pushsection.s
new file mode 100644
index 0000000..6881323
--- /dev/null
+++ b/test/MC/MachO/pushsection.s
@@ -0,0 +1,16 @@
+// RUN: llvm-mc -triple i386-apple-darwin9 %s -o - | FileCheck %s
+
+.text
+// CHECK: .section __TEXT,__text
+
+.pushsection __DATA, __data
+// CHECK: .section __DATA,__data
+
+.pushsection __TEXT, initcode
+// CHECK: .section __TEXT,initcode
+
+.popsection
+// CHECK: .section __DATA,__data
+
+.popsection
+// CHECK: .section __TEXT,__text