From 016c3a8d9e62027d4bd09948ca287cafc84e4e50 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Thu, 6 Feb 2014 17:09:53 +0100 Subject: [PATCH] test-ldso: test stack alignment Issue #1042 --- libports/src/test/ldso/main.cc | 29 +++++++++++++++++++++++++++++ os/run/ldso.run | 7 +++++++ 2 files changed, 36 insertions(+) diff --git a/libports/src/test/ldso/main.cc b/libports/src/test/ldso/main.cc index 105f365fe8..a922e7eea4 100644 --- a/libports/src/test/ldso/main.cc +++ b/libports/src/test/ldso/main.cc @@ -111,6 +111,27 @@ static void exception() { throw 666; } extern void __ldso_raise_exception(); +/************************************* + ** Helpers to test stack alignment ** + *************************************/ + +static void test_stack_align(char const *fmt, ...) __attribute__((noinline)); +static void test_stack_align(char const *fmt, ...) +{ + va_list list; + va_start(list, fmt); + + vprintf(fmt, list); + + va_end(list); +} + +struct Test_stack_align_thread : Thread<0x2000> +{ + Test_stack_align_thread() : Thread<0x2000>("test_stack_align") { } + void entry() { test_stack_align("%f\n%g\n", 3.142, 2.718); } +}; + /** * Main function of LDSO test */ @@ -167,6 +188,14 @@ int main(int argc, char **argv) lib_1_test(); + printf("test stack alignment\n"); + printf("--------------------\n"); + test_stack_align("%f\n%g\n", 3.142, 2.718); + Test_stack_align_thread t; + t.start(); + t.join(); + printf("\n"); + /* test if return value is propagated correctly by dynamic linker */ return 123; } diff --git a/os/run/ldso.run b/os/run/ldso.run index 7c523f1f8c..757f930fbe 100644 --- a/os/run/ldso.run +++ b/os/run/ldso.run @@ -98,6 +98,13 @@ compare_output_to { [init -> test-ldso] exception in lib: caught [init -> test-ldso] exception in another shared lib: caught [init -> test-ldso] +[init -> test-ldso] test stack alignment +[init -> test-ldso] -------------------- +[init -> test-ldso] +[init -> test-ldso] +[init -> test-ldso] +[init -> test-ldso] +[init -> test-ldso] [init -> test-ldso] ~Lib_2_local 55667785 [init -> test-ldso] ~Lib_1_local_2 1020303d [init -> test-ldso] ~Lib_1_local_1 5060707d