diff options
Diffstat (limited to 'testsuite/tests')
-rw-r--r-- | testsuite/tests/rts/linker/Makefile | 5 | ||||
-rw-r--r-- | testsuite/tests/rts/linker/T21618.hs | 6 | ||||
-rw-r--r-- | testsuite/tests/rts/linker/T21618.stdout | 2 | ||||
-rw-r--r-- | testsuite/tests/rts/linker/T21618_c.c | 35 | ||||
-rw-r--r-- | testsuite/tests/rts/linker/all.T | 3 |
5 files changed, 51 insertions, 0 deletions
diff --git a/testsuite/tests/rts/linker/Makefile b/testsuite/tests/rts/linker/Makefile index bbfd067f30..cc3e118243 100644 --- a/testsuite/tests/rts/linker/Makefile +++ b/testsuite/tests/rts/linker/Makefile @@ -130,3 +130,8 @@ T20494: T20918: "$(TEST_HC)" -c T20918_v.cc -o T20918_v.o echo hello | '$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) T20918_v.o T20918.hs + +.PHONY: T21618 +T21618: + "$(TEST_HC)" -c T21618_c.c -o T21618_c.o + echo main | '$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) T21618_c.o T21618.hs diff --git a/testsuite/tests/rts/linker/T21618.hs b/testsuite/tests/rts/linker/T21618.hs new file mode 100644 index 0000000000..772b96048e --- /dev/null +++ b/testsuite/tests/rts/linker/T21618.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +foreign import ccall unsafe "test" test :: IO () + +main :: IO () +main = test diff --git a/testsuite/tests/rts/linker/T21618.stdout b/testsuite/tests/rts/linker/T21618.stdout new file mode 100644 index 0000000000..4c84c67ed7 --- /dev/null +++ b/testsuite/tests/rts/linker/T21618.stdout @@ -0,0 +1,2 @@ +hello 42 43 44 + diff --git a/testsuite/tests/rts/linker/T21618_c.c b/testsuite/tests/rts/linker/T21618_c.c new file mode 100644 index 0000000000..c0adbcaa07 --- /dev/null +++ b/testsuite/tests/rts/linker/T21618_c.c @@ -0,0 +1,35 @@ +#include <stddef.h> +#include <stdio.h> + +// This test tries to ensure not only that all .ctors sections are run +// (#21618), but also that they are run in the right order (#21847). + +int n1 = 0; +int n2 = 0; +int n3 = 0; + +// This should be run first +void ctor1(void) { + n1 = 42; +} + +__attribute__((section(".ctors.2000"))) void* ctor_list1[] = { &ctor1 }; + +// This should be run second +void ctor2(void) { + n2 = n1+1; +} + +__attribute__((section(".ctors.1000"))) void * ctor_list2[] = { &ctor2 }; + +// This should be run last +void ctor3(void) { + n3 = n2+1; +} + +__attribute__((section(".ctors"))) void * ctor_list3[] = { &ctor3 }; + +void test(void) { + printf("hello %d %d %d\n", n1, n2, n3); +} + diff --git a/testsuite/tests/rts/linker/all.T b/testsuite/tests/rts/linker/all.T index 65fa8e0362..12c02fdea9 100644 --- a/testsuite/tests/rts/linker/all.T +++ b/testsuite/tests/rts/linker/all.T @@ -128,3 +128,6 @@ test('T20918', req_rts_linker], makefile_test, ['T20918']) +test('T21618', + [unless(opsys('mingw32'), skip), req_rts_linker], + makefile_test, ['T21618']) |