ZSShen / ProbeDroid

A SDK for the creation of analysis tools without obtaining app source code in order to profile runtime performance, examine code coverage, and track high-risk behaviors of a given app on Android 5.0 and above.
MIT License
197 stars 37 forks source link

NDK build problem #1

Open hsucw opened 8 years ago

hsucw commented 8 years ago

On OS X, I try to build the libProbeDroid.so Everything is fine until the linker get error

[x86] Compile : ProbeDroid <= debug.c ... [x86] Compile++ : ProbeDroid <= org_probedroid_instrument.cc [x86] SharedLibrary : libProbeDroid.so /IGNORED_PATH/../../../../i686-linux-android/bin/ld: warning: shared library text segment is not shareable /IGNORED_PATH/i686-linux-android/bin/ld: error: treating warnings as errors collect2: error: ld returned 1 exit status make: *** [/..../ProbeDroid/engine/obj/local/x86/libProbeDroid.so] Error 1

Some one suggested that adding LOCAL_LDFLAGS := --no-warn-shared-textrel

However, it is not helpful under my environment. I am using ndk-r11, and get the following message

[x86] SharedLibrary : libProbeDroid.so i686-linux-android-g++: error: unrecognized command line option '--no-warn-shared-textrel' make: *** [/.../ProbeDroid/engine/obj/local/x86/libProbeDroid.so] Error 1

Should the compile flag add -fPIC ? or any idea?

ZSShen commented 8 years ago

Appreciate for the bug report !

Could you patch the compilation flag:

LOCAL_LDFLAGS += -fPIC

in /engine/Android.mk and try again?

In my environment, it can work with the added flag.

If it also works in your machine, a patch is welcome!

ZSShen commented 8 years ago

If the previous configuration does not work,

could you switch to this flag and try again?

LOCAL_DISABLE_FATAL_LINKER_WARNINGS = true
ZSShen commented 8 years ago

Currently the assembly code in engine/arch/x86 is not written as "Position Independent" style.

Though we can turn off the warning with some aggressive flags, it is still not a super good solution.

I start to rewrite the assembly. The issue should be solved in these days.