aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyang-Ah Hana Kim <hyangah@gmail.com>2015-10-13 13:58:11 -0400
committerHyang-Ah Hana Kim <hyangah@gmail.com>2015-10-13 18:35:03 +0000
commitee07504d26a4d61ca0bc0728fea58f7b2fd52cc2 (patch)
treeda60c612456cccbf9675b44c0cd6c12a06e98c09
parent6e5ccce87f444545de14dff7190171f0b4b15a12 (diff)
downloadgo-ee07504d26a4d61ca0bc0728fea58f7b2fd52cc2.tar.xz
misc/cgo/testcshared: use -pie for android-L.
Also, handle the case where 'read' returns EINVAL instead of EBADF when the descriptor is not ready. (android 4.4.4/cyanogenmod, nexus7) Change-Id: I56c5949d27303d44a4fd0de38951b85e20cef167 Reviewed-on: https://go-review.googlesource.com/15810 Reviewed-by: Ian Lance Taylor <iant@golang.org>
-rw-r--r--misc/cgo/testcshared/main2.c2
-rwxr-xr-xmisc/cgo/testcshared/test.bash15
2 files changed, 11 insertions, 6 deletions
diff --git a/misc/cgo/testcshared/main2.c b/misc/cgo/testcshared/main2.c
index 402338339f..14a8b3f4db 100644
--- a/misc/cgo/testcshared/main2.c
+++ b/misc/cgo/testcshared/main2.c
@@ -25,7 +25,7 @@ int main(void) {
n = read(fd, buf, sizeof buf);
if (n >= 0)
break;
- if (errno != EBADF) {
+ if (errno != EBADF && errno != EINVAL) {
fprintf(stderr, "BUG: read: %s\n", strerror(errno));
return 2;
}
diff --git a/misc/cgo/testcshared/test.bash b/misc/cgo/testcshared/test.bash
index 1b7fec1549..9b50522046 100755
--- a/misc/cgo/testcshared/test.bash
+++ b/misc/cgo/testcshared/test.bash
@@ -20,7 +20,7 @@ goarch=$(go env GOARCH)
# Directory where cgo headers and outputs will be installed.
# The installation directory format varies depending on the platform.
installdir=pkg/${goos}_${goarch}_testcshared_shared
-if [ "${goos}/${goarch}" == "android/arm" ] || [ "${goos}/${goarch}" == "darwin/amd64" ]; then
+if [ "${goos}/${goarch}" == "darwin/amd64" ]; then
installdir=pkg/${goos}_${goarch}_testcshared
fi
@@ -88,9 +88,14 @@ if [ "$goos" == "linux" ]; then
fi
fi
+GOGCCFLAGS=$(go env GOGCCFLAGS)
+if [ "$goos" == "android" ]; then
+ GOGCCFLAGS="${GOGCCFLAGS} -pie"
+fi
+
# test0: exported symbols in shared lib are accessible.
# TODO(iant): using _shared here shouldn't really be necessary.
-$(go env CC) $(go env GOGCCFLAGS) -I ${installdir} -o testp main0.c libgo.$libext
+$(go env CC) ${GOGCCFLAGS} -I ${installdir} -o testp main0.c libgo.$libext
binpush testp
output=$(run LD_LIBRARY_PATH=. ./testp)
@@ -100,7 +105,7 @@ if [ "$output" != "PASS" ]; then
fi
# test1: shared library can be dynamically loaded and exported symbols are accessible.
-$(go env CC) $(go env GOGCCFLAGS) -o testp main1.c -ldl
+$(go env CC) ${GOGCCFLAGS} -o testp main1.c -ldl
binpush testp
output=$(run ./testp ./libgo.$libext)
if [ "$output" != "PASS" ]; then
@@ -115,7 +120,7 @@ linkflags="-Wl,--no-as-needed"
if [ "$goos" == "darwin" ]; then
linkflags=""
fi
-$(go env CC) $(go env GOGCCFLAGS) -o testp2 main2.c $linkflags libgo2.$libext
+$(go env CC) ${GOGCCFLAGS} -o testp2 main2.c $linkflags libgo2.$libext
binpush testp2
output=$(run LD_LIBRARY_PATH=. ./testp2)
if [ "$output" != "PASS" ]; then
@@ -125,7 +130,7 @@ fi
# test3: tests main.main is exported on android.
if [ "$goos" == "android" ]; then
- $(go env CC) $(go env GOGCCFLAGS) -o testp3 main3.c -ldl
+ $(go env CC) ${GOGCCFLAGS} -o testp3 main3.c -ldl
binpush testp3
output=$(run ./testp ./libgo.so)
if [ "$output" != "PASS" ]; then