diff --git a/base-linux/src/test/lx_hybrid_ctors/main.cc b/base-linux/src/test/lx_hybrid_ctors/main.cc
index 927e5b2f9a..4250df05f5 100644
--- a/base-linux/src/test/lx_hybrid_ctors/main.cc
+++ b/base-linux/src/test/lx_hybrid_ctors/main.cc
@@ -14,6 +14,8 @@
#include
+#include "testlib.h"
+
using namespace Genode;
@@ -23,16 +25,27 @@ struct Testapp_testclass
{
Genode::printf("Global static constructor of Genode application called\n");
}
+
+ void dummy() { }
};
-Testapp_testclass testapp_testclass;
+extern Testlib_testclass testlib_testobject;
+
+Testapp_testclass testapp_testobject;
int main(int argc, char *argv[])
{
printf("--- lx_hybrid global static constructor test ---\n");
+ /*
+ * Call a dummy function on each test object to make sure that the
+ objects don't get optimized out.
+ */
+ testlib_testobject.dummy();
+ testapp_testobject.dummy();
+
printf("--- returning from main ---\n");
return 0;
diff --git a/base-linux/src/test/lx_hybrid_ctors/testlib.cc b/base-linux/src/test/lx_hybrid_ctors/testlib.cc
index 1e579c231d..2691fdaa22 100644
--- a/base-linux/src/test/lx_hybrid_ctors/testlib.cc
+++ b/base-linux/src/test/lx_hybrid_ctors/testlib.cc
@@ -13,12 +13,16 @@
#include
-struct Testlib_testclass
-{
- Testlib_testclass()
- {
- printf("[init -> test-lx_hybrid_ctors] Global static constructor of host library called.\n");
- }
-};
+#include "testlib.h"
-Testlib_testclass testlib_testclass;
+
+Testlib_testclass::Testlib_testclass()
+{
+ printf("[init -> test-lx_hybrid_ctors] Global static constructor of host library called.\n");
+}
+
+
+void Testlib_testclass::dummy() { }
+
+
+Testlib_testclass testlib_testobject;
diff --git a/base-linux/src/test/lx_hybrid_ctors/testlib.h b/base-linux/src/test/lx_hybrid_ctors/testlib.h
new file mode 100644
index 0000000000..a0cce9028a
--- /dev/null
+++ b/base-linux/src/test/lx_hybrid_ctors/testlib.h
@@ -0,0 +1,18 @@
+/*
+ * \brief Test if global static constructors in host shared libs get called
+ * \author Christian Prochaska
+ * \date 2011-11-24
+ */
+
+/*
+ * Copyright (C) 2011-2012 Genode Labs GmbH
+ *
+ * This file is part of the Genode OS framework, which is distributed
+ * under the terms of the GNU General Public License version 2.
+ */
+
+struct Testlib_testclass
+{
+ Testlib_testclass();
+ void dummy();
+};