是否有可能从与Android NDK构建的共享库中删除符号? [英] Is it possible to remove symbols from a shared library built with Android NDK?

查看:384
本文介绍了是否有可能从与Android NDK构建的共享库中删除符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建在使用Android NDK Java应用程序使用的共享库。使用 readelf 来检查通过一个发布版本生成的lib / armeabi-V7A / libXXXlib.so 文件,它似乎包含我的本地C的所有符号(函数,变量名)/ C ++ code。

I'm building a shared library for use in a Java app using the Android NDK. Using readelf to inspect the lib/armeabi-v7a/libXXXlib.so file generated by a release build, it appears to contain all the symbols (function, variable names) of my native C/C++ code.

事实上,共享对象文件似乎是调试和发布版本相同。 (在库输出的唯一区别文件夹是与否的 gsb.setup gdbserver的文件被创建。)我重写优化的NDK与设置 APP_CFLAGS + = -O3 在我的 Application.mk ,但我不希望发布版本来生成包括 -g 标志,它确实调试符号

Indeed, the shared object file appears to be identical for the debug and release builds. (The only difference in the output in the libs folder being whether or not the gsb.setup and gdbserver files are created.) I'm overriding the optimisation set by the NDK with an APP_CFLAGS += -O3 in my Application.mk, but I wouldn't expect the release build to generate debug symbols by including the -g flag, which it does.

我发现了这样的声明评论<一个href=\"http://stackoverflow.com/questions/11304670/changes-in-android-mk-not-changing-libs#comment14889467_11304760\">'In这两种情况下,调试和发布,它留下了-g标志,因为引用的评论,我们生成的时候都复制到最终项目的libs /目录,稍后剥离的二进制文件的符号版本' ,另有说明:<一href=\"http://stackoverflow.com/questions/11304670/changes-in-android-mk-not-changing-libs#comment14903472_11304760\">'JNI找不到功能的Java,如果他们没有名字。

I found a comment on SO stating 'In both cases, debug and release, it leaves the -g flag in because, to quote the comment, "we generate symbol versions of the binaries that are later stripped when they are copied to the final project's libs/ directory"', and another stating: 'JNI cannot find the functions for java if they don't have names.'

NDK的构建肯定是剥离的的东西的从 OBJ / armeabi-V7A / libXXXlib.so 文件,因为这是比最终在库中创建一个大得多,但它仍然似乎离开我的所有功能和变量的名字不变的文件中。

ndk-build is certainly stripping something from the obj/armeabi-v7a/libXXXlib.so file, as that is much larger than the one eventually created in libs, but it still seems to be leaving all my functions' and variables' names intact in the file.

是的所有的JNI所需要的(而不仅仅是入口点到本地code)我的函数的名字呢?

Are all my functions' names required by JNI (rather than just the entry-points into the native code)?

如果不是,我怎么能去掉所有不需要的符号?

If not, how can I remove the symbols which are not required?

推荐答案

随意设置默认可见性=隐藏,并设置属性知名度=默认情况下,你需要在Windows出口(类似DLLEXPORT)的一些功能。

Feel free to set default visibility=hidden, and set attribute visibility=default for the few functions you need to export (similar to DLLEXPORT) in Windows

这篇关于是否有可能从与Android NDK构建的共享库中删除符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆