phhusson / Superuser

Keeping koush's Superuser fresh
GNU General Public License v3.0
424 stars 50 forks source link

Build issues #23

Closed mdirik closed 8 years ago

mdirik commented 8 years ago

I'm not sure if my build environment is not correctly set up or they are legitimately issues, but there is 2 related issues I encountered while trying to build Superuser.

README file lists API 19 and NDK 9b as requirements, but su binary doesn't compile correctly while using them.

$ ls $ANDROID_HOME/platforms/android-19
data/  skins/  templates/  android.jar  build.prop  framework.aidl  sdk.properties  source.properties  uiautomator.jar

$ ls `which ndk-build`
/opt/android/ndk-r9b/ndk-build

$ cat /opt/android/ndk-r9b/RELEASE.TXT
r9b

$ ndk-build 
[x86] Compile        : selinux <= fgetfilecon.c
jni/libselinux/src/fgetfilecon.c:6:23: fatal error: sys/xattr.h: No such file or directory
compilation terminated.
make: *** [obj/local/x86/objs/selinux/src/fgetfilecon.o] Error 1

It looks like sys/attr.h was added later in SDK 21.

$ find /opt/android/ndk -name xattr.h | grep 'sys/'
/opt/android/ndk/android-ndk-r10e/platforms/android-21/arch-x86/usr/include/sys/xattr.h
/opt/android/ndk/android-ndk-r10e/platforms/android-21/arch-x86_64/usr/include/sys/xattr.h
/opt/android/ndk/android-ndk-r10e/platforms/android-21/arch-mips64/usr/include/sys/xattr.h
/opt/android/ndk/android-ndk-r10e/platforms/android-21/arch-mips/usr/include/sys/xattr.h
/opt/android/ndk/android-ndk-r10e/platforms/android-21/arch-arm/usr/include/sys/xattr.h
/opt/android/ndk/android-ndk-r10e/platforms/android-21/arch-arm64/usr/include/sys/xattr.h

If I switch to NDK 10, it compiles correctly but the resulting binary won't work in Android 4.4

$ export PATH=/opt/android/ndk/android-ndk-r10e:$PATH
$ which ndk-build 
/opt/android/ndk/android-ndk-r10e/ndk-build
$ cat /opt/android/ndk/android-ndk-r10e/RELEASE.TXT 
r10e
$ ndk-build clean
...
$ ndk-build
... compiles ...

but no libs/*/placeholder exits as the README says?

$ ls libs/*/
libs/armeabi/:
su*

libs/mips/:
su*

libs/x86/:
su*

And the resulting binary doesn't work

$ adb push libs/x86/su /system/xbin/su
3255 KB/s (602704 bytes in 0.180s)
$ adb shell
# ls -lZ /system/xbin/su*                                   
-rwxrwxrwx root     root              u:object_r:system_file:s0 su
-rwsr-sr-x root     root              u:object_r:su_exec:s0 su.original

# su
CANNOT LINK EXECUTABLE: cannot locate symbol "signal" referenced by "su"...

I know selinux contexts don't match but linking problem is seperate and it is a known issue

I transcripted this on a x86 4.4 emulator but the error was same a 4.4 armv7 phone last night. I also tried changing include lines to linux/attr.h as they were on older SDK versions, but they seem to be different headers than sys/attr.h so there were compile errors. I didn't dig it further.

phhusson commented 8 years ago

You confirm it's ok for you?

mdirik commented 8 years ago

Sorry I forgot about this. Linking issue seems to be resolved (even though I couldn't get it working due to not being able to install properly). README still points to the NDK r9b, though. It doesn't work and it should point to NDK r10 instead.

Thanks!

Inphi commented 8 years ago

yeah. the readme really ought to be updated. Spent some time tackling the same issue until i bothered to check this issue.