aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Hsieh <andrewhsieh@google.com>2013-08-07 00:43:49 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2013-08-07 00:43:49 +0000
commit3746c78ab88ee2421275c9cbef9253d086171a80 (patch)
tree7ff7c94ca11f469def9492efa84542a4c3385801
parentca708601d9623de0972b536b67b2b5b1c54108a0 (diff)
parent23e3137ee2897464b051599b85a09f130d3ad05d (diff)
downloadndk-3746c78ab88ee2421275c9cbef9253d086171a80.tar.gz
Merge "Revise all static executable tests by adding -Wl,--eh-frame-hdr"
-rw-r--r--tests/device/clone/jni/Android.mk2
-rw-r--r--tests/device/issue38121/jni/Android.mk2
-rw-r--r--tests/device/static-executable/jni/Android.mk17
-rw-r--r--tests/device/static-executable/jni/main.c7
-rw-r--r--tests/device/static-executable/jni/main.cxx12
-rw-r--r--tests/device/test-wait/jni/Android.mk2
6 files changed, 29 insertions, 13 deletions
diff --git a/tests/device/clone/jni/Android.mk b/tests/device/clone/jni/Android.mk
index 3fc68eb73..df2954408 100644
--- a/tests/device/clone/jni/Android.mk
+++ b/tests/device/clone/jni/Android.mk
@@ -8,5 +8,5 @@ include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
LOCAL_MODULE := clone-static
LOCAL_SRC_FILES := clone.c
-LOCAL_LDFLAGS += -static
+LOCAL_LDFLAGS += -static -Wl,--eh-frame-hdr
include $(BUILD_EXECUTABLE)
diff --git a/tests/device/issue38121/jni/Android.mk b/tests/device/issue38121/jni/Android.mk
index 386b9ecd7..1a31faf46 100644
--- a/tests/device/issue38121/jni/Android.mk
+++ b/tests/device/issue38121/jni/Android.mk
@@ -4,5 +4,5 @@ include $(CLEAR_VARS)
LOCAL_MODULE := issue38121_main
LOCAL_SRC_FILES := main.c
LOCAL_CFLAGS += -fstack-protector-all
-LOCAL_LDFLAGS += -static
+LOCAL_LDFLAGS += -static -Wl,--eh-frame-hdr
include $(BUILD_EXECUTABLE)
diff --git a/tests/device/static-executable/jni/Android.mk b/tests/device/static-executable/jni/Android.mk
index 111bd4ea6..c14f1d36f 100644
--- a/tests/device/static-executable/jni/Android.mk
+++ b/tests/device/static-executable/jni/Android.mk
@@ -1,8 +1,19 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
-LOCAL_MODULE := static_main
-LOCAL_SRC_FILES := main.c
-LOCAL_LDFLAGS := -static # this forces the generation of a static executable
+LOCAL_MODULE := static-executable
+LOCAL_SRC_FILES := main.cxx
+LOCAL_CFLAGS += -fexceptions
+
+# Note that by default ndk-build system doesn't support static executable,
+# but option "-static" can instruct gcc to link with proper crt*o files to
+# generate static executable.
+LOCAL_LDFLAGS += -static
+
+# Be aware that -Wl,--eh-frame-hdr is also needed for "-static" (at least for
+# x86 and mips which use eh frames) since crt files are now in C, and the trick
+# in the previous *S file to iterate all eh frames and record ranges is gone
+LOCAL_LDFLAGS += -Wl,--eh-frame-hdr
+
include $(BUILD_EXECUTABLE)
diff --git a/tests/device/static-executable/jni/main.c b/tests/device/static-executable/jni/main.c
deleted file mode 100644
index 938730ab5..000000000
--- a/tests/device/static-executable/jni/main.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <stdio.h>
-
-int main(void)
-{
- printf("Hello static world!\n");
- return 0;
-}
diff --git a/tests/device/static-executable/jni/main.cxx b/tests/device/static-executable/jni/main.cxx
new file mode 100644
index 000000000..d40e0a46e
--- /dev/null
+++ b/tests/device/static-executable/jni/main.cxx
@@ -0,0 +1,12 @@
+#include <stdio.h>
+int main()
+{
+ printf ("Hello 1\n");
+ try {
+ throw 20;
+ } catch(...) {
+ printf ("catch\n");
+ }
+ printf ("Hello 2\n");
+ return 0;
+}
diff --git a/tests/device/test-wait/jni/Android.mk b/tests/device/test-wait/jni/Android.mk
index 851a270a4..94d662a49 100644
--- a/tests/device/test-wait/jni/Android.mk
+++ b/tests/device/test-wait/jni/Android.mk
@@ -8,6 +8,6 @@ include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
LOCAL_MODULE := test_wait-static
LOCAL_SRC_FILES := test_wait.c
-LOCAL_LDFLAGS += -static
+LOCAL_LDFLAGS += -static -Wl,--eh-frame-hdr
include $(BUILD_EXECUTABLE)