Issue including executable with Android application when using Jelly Bean
Asked Answered
L

1

1

I have ported a few useful free/open source tools to Android. One is Octave and the other is gnuplot. They work together in unison to provide Matlab like capability for free (as in speech) and free (as in beer). I have packed them inside apps in an interesting way. Specifically,

1) I include the executable and shared libraries inside the libs/armeabi directory. Have to give them funny name because of android naming conventions.

2) I create directories bin/ and mylib/. I give them full permissions.

3) I create links from bin/ to the executable in the unpacked lib/ directory. I give them the correct names and full permissions.

4) I create links from mylib/ to the shared libaries in the unpacked lib/ directory. I give them the correct names and full permissions.

5) I then use ld-linux.so.3 which is one of the libraries now in the mylib/ directory and the--library-path option to point at the mylib/ directory to launch the executable from the Android Terminal Emulator.

Octave works perfectly in all version of Android doing this, but gnuplot gives this error when I attempt to launch it when running Jelly Bean only:

error while loading shared libraries: gnuplot: failed to map segment 
from shared object: Operation not permitted.

So, why would I have this error for one of these two executables made the same way? Why only in Jelly Bean? Also, on JB, if I make myself the super user, it all works again.

Any thoughts on how to debug? I have confirmed that all files are there and have the permissions that I intended they have.

Please help. You would be helping a free, open source, educational and useful app if you do.

Lazulite answered 20/11, 2012 at 6:48 Comment(9)
Tried explaining it differently, maybe better, here: #13502656Lazulite
I don't know if this works but you could try to recompile the gnuplot library with "console.writeline" and/or "Log.d" on specific lines you think this error occurs and write out some information.Canady
Looking in the JellyBean source, I see the string "failed to map segment from shared object" is embedded in the binary prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6/sysroot/usr/lib/ld-2.7.so . Does anyone know how to find the exact source that was built from? Reading the source could give clues. Is it stored somewhere on the android source site? I can't find it.Haematocele
Android's unique ld is part of the bionic libc sources. But why you are using an ld-linux on an Android device needs explaining!Jaco
Doing Log.d or console.writeline does not help. Not a single line of gnuplot seems to be executing. It seems to be ld-linux or something that it calls to help it seems to not like something about how the binary is built.Lazulite
ld (the android version or not) has this error built in. The normal cause of this error is you either don't have the correct permissions for the file (not my issue) or you are trying to execute a file that exists on a noexec mount (not my issue).Lazulite
I am intending to have ld-linux use my version of ld and my version of the shared libs, not the android ones.Lazulite
I found a work around, by comparing how the two executables are built, but have no idea why it works and want a cleaner solution. I built a shared library out of all the .o files instead of building an executable from them. I then built a simple executable that used that shared library and called its main function.Lazulite
Why use ld-linux? It is a long story, but it has proven to be the correct route. I will explain the journey in a blog post eventually. I know it is strange, but there are reasons.Lazulite
L
0

The issue was with how the executables were compiled. They needed to be compiled with a cross compiler that properly supported newer arm devices. The compiler I used generated executables that would only work on a subset of arm devices. The issue was not with the different versions of android.

Lazulite answered 21/8, 2014 at 18:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.