summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2012-08-28 16:23:16 +0300
committerTor Lillqvist <tml@iki.fi>2012-09-24 17:00:44 +0300
commitcff0c7d492432842c45a9628e579a60b2ca5d542 (patch)
treecd83dddf9838bf6fec3033b4562ed0792297cd63
parentadd80cede10c3f4afb811cdbc9d5c151a0fbf412 (diff)
Further changes for an attempt to use the faulty.lib linker on Android
Change-Id: Ib9422711e981ff63d6e4f197c2e04a25c22e8adc
-rw-r--r--configure.in20
-rw-r--r--sal/Library_lo-bootstrap.mk8
-rw-r--r--sal/android/lo-bootstrap.c12
3 files changed, 39 insertions, 1 deletions
diff --git a/configure.in b/configure.in
index 02ad841174b0..51397f6847c2 100644
--- a/configure.in
+++ b/configure.in
@@ -225,6 +225,26 @@ if test -n "$with_android_ndk"; then
test -z "$CC" && CC="$ANDROID_ABI_PREBUILT_BIN/$android_gcc_prefix-gcc $ANDROIDCFLAGS"
test -z "$CXX" && CXX="$ANDROID_ABI_PREBUILT_BIN/$android_gcc_prefix-g++ $ANDROIDCXXFLAGS"
+
+ AC_MSG_CHECKING([whether the CRT objects have text relocations])
+ echo 'int foo() { return 0; }' > conftest.cpp
+ if AC_TRY_COMMAND(${CXX} -shared -o conftest.so conftest.cpp 1>&5) &&
+ test -s conftest.so; then
+ if $android_gcc_prefix-readelf -d conftest.so | grep -q TEXTREL; then
+ crt_has_text_relocations=yes
+ else
+ crt_has_text_relocations=no
+ fi
+ else
+ AC_ERROR([couldn't compile a simple C file])
+ fi
+ AC_MSG_RESULT([$crt_has_text_relocations])
+ rm -rf conftest*
+ if test $crt_has_text_relocations = yes; then
+ # We should build only libraries for Android anyway, no executables
+ CXX="$CXX -nostartfiles"
+ CC="$CC -nostartfiles"
+ fi
fi
AC_SUBST(ANDROID_NDK_HOME)
AC_SUBST(ANDROID_NDK_TOOLCHAIN_VERSION_SUBDIR)
diff --git a/sal/Library_lo-bootstrap.mk b/sal/Library_lo-bootstrap.mk
index 79ebd90760ad..8e9332972980 100644
--- a/sal/Library_lo-bootstrap.mk
+++ b/sal/Library_lo-bootstrap.mk
@@ -32,7 +32,7 @@ $(eval $(call gb_Library_add_libs,lo-bootstrap,\
-lz \
-llog \
-landroid \
- -lgnustl_static \
+ -lstlport_static \
))
$(eval $(call gb_Library_add_cobjects,lo-bootstrap,\
@@ -48,10 +48,16 @@ $(eval $(call gb_Library_add_cxxobjects,lo-bootstrap,\
))
$(eval $(call gb_Library_set_include,lo-bootstrap,\
+ -I$(ANDROID_NDK_HOME)/sources/cxx-stl/stlport/stlport \
$$(INCLUDE) \
-I$(SRCDIR)/sal/android/faulty.lib \
-I$(SRCDIR)/sal/inc \
-DHAVE_DLADDR \
))
+$(eval $(call gb_Library_set_ldflags,lo-bootstrap,\
+ -L$(ANDROID_NDK_HOME)/sources/cxx-stl/stlport/libs/$(ANDROID_APP_ABI) \
+ $$(LDFLAGS) \
+))
+
# vim: set noet sw=4 ts=4:
diff --git a/sal/android/lo-bootstrap.c b/sal/android/lo-bootstrap.c
index f1498695395f..9bbb33f25415 100644
--- a/sal/android/lo-bootstrap.c
+++ b/sal/android/lo-bootstrap.c
@@ -69,6 +69,18 @@
#define MAX(a,b) ((a) > (b) ? (a) : (b))
+extern void *__wrap_dlopen(const char *path, int flags);
+extern const char *__wrap_dlerror(void);
+extern void *__wrap_dlsym(void *handle, const char *symbol);
+extern int __wrap_dlclose(void *handle);
+extern int __wrap_dladdr(void *addr, Dl_info *info);
+
+#define dlopen __wrap_dlopen
+#define dlerror __wrap_dlerror
+#define dlsym __wrap_dlsym
+#define dlclose __wrap_dlclose
+#define dladdr __wrap_dladdr
+
struct engine {
int dummy;
};