summaryrefslogtreecommitdiff
path: root/testsuite/tests/rts
diff options
context:
space:
mode:
authorArtem Pyanykh <artempyanykh@gmail.com>2019-02-11 14:05:34 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-03-20 19:52:39 -0400
commit3cdcc0b55de5f7a35dc12430f021a665b0477e95 (patch)
tree31e73dbfb69a7077b86afed85dabde2f183e3046 /testsuite/tests/rts
parent7bbfb789913b84660bc743aeffee06e18cbde2f0 (diff)
downloadhaskell-3cdcc0b55de5f7a35dc12430f021a665b0477e95.tar.gz
Add a linker test re: section alignment
Diffstat (limited to 'testsuite/tests/rts')
-rw-r--r--testsuite/tests/rts/linker/Makefile5
-rw-r--r--testsuite/tests/rts/linker/aligned_mem_access.c14
-rw-r--r--testsuite/tests/rts/linker/aligned_mem_access.stdout2
-rw-r--r--testsuite/tests/rts/linker/all.T7
4 files changed, 28 insertions, 0 deletions
diff --git a/testsuite/tests/rts/linker/Makefile b/testsuite/tests/rts/linker/Makefile
index 838a83a2c7..2320d34d83 100644
--- a/testsuite/tests/rts/linker/Makefile
+++ b/testsuite/tests/rts/linker/Makefile
@@ -6,3 +6,8 @@ unsigned_reloc_macho_x64:
as -o unsigned_reloc_macho_x64.o unsigned_reloc_macho_x64.s
'$(TEST_HC)' $(TEST_HC_OPTS_NO_RTSOPTS) -v0 --make -no-rtsopts-suggestions -no-hs-main -o runner runner.c
./runner unsigned_reloc_macho_x64.o getAnswer
+
+aligned_mem_access:
+ cc -c -o aligned_mem_access.o aligned_mem_access.c
+ '$(TEST_HC)' $(TEST_HC_OPTS_NO_RTSOPTS) -v0 --make -no-rtsopts-suggestions -no-hs-main -o runner runner.c
+ ./runner aligned_mem_access.o foo
diff --git a/testsuite/tests/rts/linker/aligned_mem_access.c b/testsuite/tests/rts/linker/aligned_mem_access.c
new file mode 100644
index 0000000000..cef90c3485
--- /dev/null
+++ b/testsuite/tests/rts/linker/aligned_mem_access.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <immintrin.h>
+
+__m128 mvec = {1.0, 2.0, 3.0, 42.0};
+float fvec[] = {.0, .0, .0, .0};
+
+/* Uses movaps instruction to move data between XMMn <-> mem. Fails
+ * with segfault when data section is not properly aligned (16 byte).
+ */
+long foo(void)
+{
+ _mm_store_ps(fvec, mvec);
+ return (long) fvec[3];
+}
diff --git a/testsuite/tests/rts/linker/aligned_mem_access.stdout b/testsuite/tests/rts/linker/aligned_mem_access.stdout
new file mode 100644
index 0000000000..4b728c2ee1
--- /dev/null
+++ b/testsuite/tests/rts/linker/aligned_mem_access.stdout
@@ -0,0 +1,2 @@
+Linking: path = aligned_mem_access.o, symname = _foo
+42 \ No newline at end of file
diff --git a/testsuite/tests/rts/linker/all.T b/testsuite/tests/rts/linker/all.T
index 66c2156660..23d79d3918 100644
--- a/testsuite/tests/rts/linker/all.T
+++ b/testsuite/tests/rts/linker/all.T
@@ -7,3 +7,10 @@ test('unsigned_reloc_macho_x64',
unless(arch('x86_64'), skip)
],
run_command, ['$MAKE -s --no-print-directory unsigned_reloc_macho_x64'])
+
+test('aligned_mem_access',
+ [
+ extra_files(['runner.c', 'aligned_mem_access.c']),
+ unless(opsys('darwin') and arch('x86_64'), expect_broken(13624))
+ ],
+ run_command, ['$MAKE -s --no-print-directory aligned_mem_access'])