Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working on x86 platform #1

Open
ctjhai opened this issue Sep 1, 2014 · 5 comments
Open

Not working on x86 platform #1

ctjhai opened this issue Sep 1, 2014 · 5 comments

Comments

@ctjhai
Copy link

ctjhai commented Sep 1, 2014

I tried to create an obfuscated binary for x86 platform, but it failed with linker error that it did not understand sysroot option. See the log below

rm -f /Users/test/scratchpad/AndroidObfuscation-NDK/libs/armeabi/lib_.so /Users/test/scratchpad/AndroidObfuscation-NDK/libs/armeabi-v7a/lib_.so /Users/test/scratchpad/AndroidObfuscation-NDK/libs/armeabi-v7a-hard/lib_.so /Users/test/scratchpad/AndroidObfuscation-NDK/libs/mips/lib_.so /Users/test/scratchpad/AndroidObfuscation-NDK/libs/x86/lib_.so rm -f /Users/test/scratchpad/AndroidObfuscation-NDK/libs/armeabi/gdbserver /Users/test/scratchpad/AndroidObfuscation-NDK/libs/armeabi-v7a/gdbserver /Users/test/scratchpad/AndroidObfuscation-NDK/libs/armeabi-v7a-hard/gdbserver /Users/test/scratchpad/AndroidObfuscation-NDK/libs/mips/gdbserver /Users/test/scratchpad/AndroidObfuscation-NDK/libs/x86/gdbserver rm -f /Users/test/scratchpad/AndroidObfuscation-NDK/libs/armeabi/gdb.setup /Users/test/scratchpad/AndroidObfuscation-NDK/libs/armeabi-v7a/gdb.setup /Users/test/scratchpad/AndroidObfuscation-NDK/libs/armeabi-v7a-hard/gdb.setup /Users/test/scratchpad/AndroidObfuscation-NDK/libs/mips/gdb.setup /Users/test/scratchpad/AndroidObfuscation-NDK/libs/x86/gdb.setup [x86] Compile : obfuscated <= obfuscationTest.c /Applications/ADT/android-ndk-r10/toolchains/obfuscator-llvm-3.4/prebuilt/darwin-x86_64/bin/clang -MMD -MP -MF /Users/test/scratchpad/AndroidObfuscation-NDK/obj/local/x86/objs/obfuscated/obfuscationTest.o.d -gcc-toolchain /Applications/ADT/android-ndk-r10/toolchains/x86-4.8/prebuilt/darwin-x86_64 -target i686-none-linux-android -ffunction-sections -funwind-tables -fstack-protector -fPIC -no-canonical-prefixes -O2 -g -DNDEBUG -fomit-frame-pointer -fstrict-aliasing -I/Users/test/scratchpad/AndroidObfuscation-NDK/jni -DANDROID -mllvm -sub -mllvm -fla -mllvm -bcf -Wa,--noexecstack -Wformat -Werror=format-security -I/Applications/ADT/android-ndk-r10/platforms/android-9/arch-x86/usr/include -c /Users/test/scratchpad/AndroidObfuscation-NDK/jni/obfuscationTest.c -o /Users/test/scratchpad/AndroidObfuscation-NDK/obj/local/x86/objs/obfuscated/obfuscationTest.o [x86] Executable : obfuscated /Applications/ADT/android-ndk-r10/toolchains/obfuscator-llvm-3.4/prebuilt/darwin-x86_64/bin/clang++ -Wl,--gc-sections -Wl,-z,nocopyreloc --sysroot=/Applications/ADT/android-ndk-r10/platforms/android-9/arch-x86 -Wl,-rpath-link=/Applications/ADT/android-ndk-r10/platforms/android-9/arch-x86/usr/lib -Wl,-rpath-link=/Users/test/scratchpad/AndroidObfuscation-NDK/obj/local/x86 /Users/test/scratchpad/AndroidObfuscation-NDK/obj/local/x86/objs/obfuscated/obfuscationTest.o -lgcc -gcc-toolchain /Applications/ADT/android-ndk-r10/toolchains/x86-4.8/prebuilt/darwin-x86_64 -target i686-none-linux-android -no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -static -lc -lm -o /Users/test/scratchpad/AndroidObfuscation-NDK/obj/local/x86/obfuscated ld: unknown option: --sysroot=/Applications/ADT/android-ndk-r10/platforms/android-9/arch-x86 clang++: error: linker command failed with exit code 1 (use -v to see invocation) make: *_\* [/Users/test/scratchpad/AndroidObfuscation-NDK/obj/local/x86/obfuscated] Error 1

There is no issue with ARM and MIPS platforms though.

Any idea on this?

@ctjhai
Copy link
Author

ctjhai commented Sep 1, 2014

I found some additional information after some digging around. If I set the target to ARM and execute the following command:

/Applications/ADT/android-ndk-r10/toolchains/obfuscator-llvm-3.4/prebuilt/darwin-x86_64/bin/clang++ -v --sysroot=/Applications/ADT/android-ndk-r10/platforms/android-3/arch-arm -target armv5te-none-linux-androideabi -gcc-toolchain /Applications/ADT/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/

and I have the following output:

Obfuscator-clang version 3.4 (tags/RELEASE_34/final) (based on LLVM 3.4svn)
Target: armv5te-none-linux-androideabi
Thread model: posix
Found candidate GCC installation: /Applications/ADT/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.8
Selected GCC installation: /Applications/ADT/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.8

On the other hand, if I set the target to i686 or x86, GCC installation could not be found

/Applications/ADT/android-ndk-r10/toolchains/obfuscator-llvm-3.4/prebuilt/darwin-x86_64/bin/clang++ -v --sysroot=/Applications/ADT/android-ndk-r10/platforms/android-9/arch-x86 -target i686-none-linux-android -gcc-toolchain /Applications/ADT/android-ndk-r10/toolchains/x86-4.8/prebuilt/darwin-x86_64/
Obfuscator-clang version 3.4 (tags/RELEASE_34/final) (based on LLVM 3.4svn)
Target: i686-none-linux-android
Thread model: posix
Selected GCC installation: 

@Fuzion24
Copy link
Owner

Fuzion24 commented Sep 1, 2014

I have not used the Android NDK + clang to build a native x86 application. It is possible that the NDK doesn't support building via clang for x86. Did you try building a simple hello world app for x86 (without the obfuscator) using the stock NDK?

@ctjhai
Copy link
Author

ctjhai commented Sep 1, 2014

Yes, if I use the stock NDK, it can build for all supported platforms, including x86. Having said that, I have not run the resulting binary on x86 platform.

@Fuzion24
Copy link
Owner

Fuzion24 commented Sep 2, 2014

You can build for x86 using clang with the ndk?

@ctjhai
Copy link
Author

ctjhai commented Sep 2, 2014

Confirmed, I can build my JNI shared library with clang. On my Application.mk file, I have the following entries:

APP_ABI := x86
NDK_TOOLCHAIN_VERSION := clang3.4

Just for your information, I am using Android NDK r10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants