OSDN Git Service

Fixed runtime linkage problems for libOpenSLES and libOpenMAXAL
authorAndrew Hsieh <andrewhsieh@google.com>
Tue, 8 May 2012 14:55:10 +0000 (22:55 +0800)
committerAndrew Hsieh <andrewhsieh@google.com>
Tue, 8 May 2012 14:55:10 +0000 (22:55 +0800)
Libraries libOpenSLES and libOpenMAXAL depend on liblog but Android.mk
doesn't specify it.  Native app links libOpenSLES or libOpenMAXAL
may fail with the following error message (taking
$NDK/samples/native-media as an example)

E/AndroidRuntime(  824): Caused by: java.lang.UnsatisfiedLinkError:
Cannot load library: link_image[2260]:    82 could not load needed
library 'libOpenMAXAL.so' for 'libnative-media-jni.so'
(mips_relocate_got[1804]:    82 In 'libOpenMAXAL.so',
can't locate symbol __android_log_assert)

The root cause is that both libOpenSLES.so and libOpenMAXAL.so depends on
liblog (containing the offending __android_log_assert) but Android makefile
doesn't specify it.  The reason that linker doesn't complain about it
is because "--gc-sections" causes linker to "garbage-collect" which
removes unused (in this case "invisible") functions __assert/__assert2
in both shared libraries.  Unfortunately, due to a bug (recently fixed
in 2.22.52 http://sourceware.org/bugzilla/show_bug.cgi?id=13811), linker
forgot to also remove references to dead function __android_log_assert
called in __assert/__assert2.

In theory this should affect all Android devices for native app linking
libOpenMAXAL.so or libOpenSLES.so, but it seems at this moment only MIPS-based
device is affected.

Fixed Android.mk to make it explicit.

bug: http://code.google.com/p/android/issues/detail?id=30179
related CL: https://android-review.googlesource.com/#/c/36302/

Change-Id: I61655a77d85f57cf103f9ac51505dc3d58f7c866

wilhelm/src/Android.mk

index 6da321a..94c99a5 100644 (file)
@@ -207,7 +207,7 @@ LOCAL_PRELINK_MODULE := false
 LOCAL_MODULE_TAGS := optional
 LOCAL_CFLAGS += -x c++ -DLI_API= -fvisibility=hidden -UNDEBUG \
                 -DSL_API='__attribute__((visibility("default")))'
-LOCAL_SHARED_LIBRARIES := libwilhelm
+LOCAL_SHARED_LIBRARIES := libwilhelm liblog
 include $(BUILD_SHARED_LIBRARY)
 
 include $(CLEAR_VARS)
@@ -222,5 +222,5 @@ LOCAL_PRELINK_MODULE := false
 LOCAL_MODULE_TAGS := optional
 LOCAL_CFLAGS += -x c++ -DLI_API= -fvisibility=hidden -UNDEBUG \
                 -DXA_API='__attribute__((visibility("default")))'
-LOCAL_SHARED_LIBRARIES := libwilhelm
+LOCAL_SHARED_LIBRARIES := libwilhelm liblog
 include $(BUILD_SHARED_LIBRARY)