--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at http://groups.google.com/group/android-ndk?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
On Wed, Mar 20, 2013 at 8:11 PM, pps <pavlov...@gmail.com> wrote:
> Ok, I figured it out.
>
> add-application.mk:128: Android NDK: WARNING: APP_PLATFORM android-14 is
> larger than android:minSdkVersion 8 in ./AndroidManifest.xml
>
> When I compiled with APP_PLATFORM=android-8 I got a link error for
> pthread_setname_np
>
> I removed reference to this function and now my app loads fine.
> What's the best way to access the function "dynamically". On Win32 I'd
> LoadLibrary and GetProcAddr. I don't want to do that on Android since
> location of pthread functions might change in the future.
The *nix equivalent is dlopen and dlsym (more below).
> Can I add some "weak" symbol attribute so that locally defined function
> would be used if not overridden by any linked shared object? Is there such
> concept on Android/Linux?
Yes. See the weak attribute at
http://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Function-Attributes.html.
ldd does not exist for android (what a weirdo broken linux is this Android?!)
On Wednesday, March 20, 2013 8:34:56 PM UTC-4, Jeffrey Walton wrote:On Wed, Mar 20, 2013 at 8:11 PM, pps <pavlov...@gmail.com> wrote:
> Ok, I figured it out.
>
> add-application.mk:128: Android NDK: WARNING: APP_PLATFORM android-14 is
> larger than android:minSdkVersion 8 in ./AndroidManifest.xml
>
> When I compiled with APP_PLATFORM=android-8 I got a link error for
> pthread_setname_np
>
> I removed reference to this function and now my app loads fine.
> What's the best way to access the function "dynamically". On Win32 I'd
> LoadLibrary and GetProcAddr. I don't want to do that on Android since
> location of pthread functions might change in the future.
The *nix equivalent is dlopen and dlsym (more below).
I know about dlopen/dlsym, the issue is that I don't know where is that pthread_setname_np defined.
Today, on most androids it's in libc.so I suppose, tomorrow it might be pthread.so. I had an android device that had libc.so.6 and pthread.so; basically, dlopen isn't the best idea in this case.
> Can I add some "weak" symbol attribute so that locally defined function
> would be used if not overridden by any linked shared object? Is there such
> concept on Android/Linux?
Yes. See the weak attribute at
http://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Function-Attributes.html.
Yep, that works. GCC has weak externals for Win32 that behave the way I described. The weak symbol on ELFs is either 0 or imported (e.g. I cannot define my alternative implementation).
Back to the original question: what's the best way to find unresolved external symbol? I pulled all shared objects from target device, what tool I can use that could tell me that symbol XYZ isn't defined anywhere? Is there such tool that works on Windows, or, can I find that using utils from the NDK?
On Thu, Mar 21, 2013 at 2:41 AM, pps <pavlov...@gmail.com> wrote:On Wednesday, March 20, 2013 8:34:56 PM UTC-4, Jeffrey Walton wrote:On Wed, Mar 20, 2013 at 8:11 PM, pps <pavlov...@gmail.com> wrote:
> Ok, I figured it out.
>
> add-application.mk:128: Android NDK: WARNING: APP_PLATFORM android-14 is
> larger than android:minSdkVersion 8 in ./AndroidManifest.xml
>
> When I compiled with APP_PLATFORM=android-8 I got a link error for
> pthread_setname_np
>
> I removed reference to this function and now my app loads fine.
> What's the best way to access the function "dynamically". On Win32 I'd
> LoadLibrary and GetProcAddr. I don't want to do that on Android since
> location of pthread functions might change in the future.
The *nix equivalent is dlopen and dlsym (more below).
I know about dlopen/dlsym, the issue is that I don't know where is that pthread_setname_np defined.
Today, on most androids it's in libc.so I suppose, tomorrow it might be pthread.so. I had an android device that had libc.so.6 and pthread.so; basically, dlopen isn't the best idea in this case.
On Android, it will always be libc.so. There is no way future versions of the platform will break the ABI on purpose, this is not GNU/Linux :-)
> Can I add some "weak" symbol attribute so that locally defined function
> would be used if not overridden by any linked shared object? Is there such
> concept on Android/Linux?
Yes. See the weak attribute at
http://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Function-Attributes.html.
Yep, that works. GCC has weak externals for Win32 that behave the way I described. The weak symbol on ELFs is either 0 or imported (e.g. I cannot define my alternative implementation).
weak symbols might not be properly handled by the Froyo dynamic linker. IIRC, support was only added later. I'd suggest keeping using dlopen()/dlsym() is you're targetting anything older than Gingerbread.
Back to the original question: what's the best way to find unresolved external symbol? I pulled all shared objects from target device, what tool I can use that could tell me that symbol XYZ isn't defined anywhere? Is there such tool that works on Windows, or, can I find that using utils from the NDK?
On more recent versions of the platform, the dynamic linker will tell you in logcat which symbol is actually missing.
You can also list the symbols exported by an ARM shared library with "arm-linux-androideabi-nm --defined-only /path/to/libfoo.so", this can be useful to look at the content of $NDK/platforms/android-$PLATFORM/arch-$ARCH/usr/lib/Use "--undefined-only" instead of "--defined-only" to see which symbols your own library depends on.If you have an Android source tree checkout, $ANDROID/development/ndk/platforms/android-$PLATFORM/arch-$ARCH/symbols/ contains various text files listing the exact public symbols exported by the NDK for each system library.
On Android, it will always be libc.so. There is no way future versions of the platform will break the ABI on purpose, this is not GNU/Linux :-)
At some point I had to work on an Android based tv or stb and it was different. It had pthreads.so (libpthread or whatever regular name on linux).
Are you saying that nm will load libfoo.so and other libraries that libfoo.so requires? If not, then it's quite useless.
I know how to list symbols and, theoretically, I could then see what symbol does not exist in any of the libraries present on the phone (I did it once sorting them all then comparing lists of names with araxis and removing matching names). This task of iterating over all required symbols and checking if they are exported by any of linked in objects is best done by computers and that's what I'm asking. Very often that loading issue was related to some gcc internal symbols that aren't exported for some reason here and there and it's difficult to go over all these obscure __fsdvsi style names.
some newer androids do show what's the missing symbol name, but sometimes (like in this case now) mobiles that do have that newer android also do not have loading issues. So, I really need a tool that does that. I recall, that more than a year I had it (probable it was from some elftools or some library and I think i was able to do what need on windows, but I absolutely don't remember how I did it back then).
On Thu, Mar 21, 2013 at 9:48 PM, pps <pavlov...@gmail.com> wrote:On Android, it will always be libc.so. There is no way future versions of the platform will break the ABI on purpose, this is not GNU/Linux :-)
At some point I had to work on an Android based tv or stb and it was different. It had pthreads.so (libpthread or whatever regular name on linux).
Some "Android-based" devices do all kind of weird stuff, and they're definitely not compatible. You should not expect to use the official SDK/NDK tools to write apps for them. No idea what they provide for development though.There is also the special case of GoogleTV. For historical reasons, they have a GLibc-based userland, which is why they cannot support NDK-based applications. Hopefully they'll fix this in a future revision of the platform, but frankly I don't know much.Apart from that, the NDK official ABIs are carefully maintained to ensure they never break existing applications.
w these errors disappear. In fact, latest jelly bean mentions that incorrectly exported exidx (or something like that) was removed, but it breaks builds compiled with r8d if gold was used for linking and unwinder facility was used (I'm waiting for the fix, meanwhile, we have to wait half an hour every time bfd does it's job).