Java libavcodec.so:具有文本重定位
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32346402/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
libavcodec.so: has text relocations
提问by LS_
I'm testing Android 6.0 on a Nexus 5 and i'm using Metaio (I know that the service is going to end on the 15th of december but for that date we'll move to another AR platform). The problem is that when I start the ARActivity I get the following error:
我正在 Nexus 5 上测试 Android 6.0,我正在使用 Metaio(我知道该服务将于 12 月 15 日结束,但在那一天我们将转移到另一个 AR 平台)。问题是,当我启动 ARActivity 时,出现以下错误:
09-02 08:45:11.138: E/AndroidRuntime(6141): java.lang.UnsatisfiedLinkError: dlopen failed: /data/app/com.myapp.myapp/lib/arm/libavcodec.so: has text relocations
09-02 08:45:11.138: E/AndroidRuntime(6141): at java.lang.Runtime.loadLibrary(Runtime.java:372)
09-02 08:45:11.138: E/AndroidRuntime(6141): at java.lang.System.loadLibrary(System.java:1076)
09-02 08:45:11.138: E/AndroidRuntime(6141): at com.metaio.sdk.jni.IMetaioSDKAndroid.loadNativeLibs(IMetaioSDKAndroid.java:54)
09-02 08:45:11.138: E/AndroidRuntime(6141): at metaioCloudPlugin.SplashActivity.loadNativeLibs(SplashActivity.java:37)
09-02 08:45:11.138: E/AndroidRuntime(6141): at metaioCloudPlugin.SplashActivity.onCreate(SplashActivity.java:68)
09-02 08:45:11.138: E/AndroidRuntime(6141): at android.app.Activity.performCreate(Activity.java:6237)
09-02 08:45:11.138: E/AndroidRuntime(6141): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
09-02 08:45:11.138: E/AndroidRuntime(6141): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
09-02 08:45:11.138: E/AndroidRuntime(6141): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
09-02 08:45:11.138: E/AndroidRuntime(6141): at android.app.ActivityThread.-wrap11(ActivityThread.java)
09-02 08:45:11.138: E/AndroidRuntime(6141): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
09-02 08:45:11.138: E/AndroidRuntime(6141): at android.os.Handler.dispatchMessage(Handler.java:102)
09-02 08:45:11.138: E/AndroidRuntime(6141): at android.os.Looper.loop(Looper.java:148)
09-02 08:45:11.138: E/AndroidRuntime(6141): at android.app.ActivityThread.main(ActivityThread.java:5417)
09-02 08:45:11.138: E/AndroidRuntime(6141): at java.lang.reflect.Method.invoke(Native Method)
09-02 08:45:11.138: E/AndroidRuntime(6141): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
09-02 08:45:11.138: E/AndroidRuntime(6141): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Does anyone know a possible solution for this or at least a workaround? I'm struggling to find a solution but I can't understand what the problem could be.
有谁知道可能的解决方案或至少是一种解决方法?我正在努力寻找解决方案,但我无法理解问题可能是什么。
采纳答案by christin
Today, I got the same error messages when testing my app with Android 6.0 on a Nexus 6 (Motorola). I solved my issue by checking the targetSDKVersion in the manifest file. Using "22" and not "23" as targetSDKVersion solved it. (See below)
今天,在 Nexus 6(摩托罗拉)上使用 Android 6.0 测试我的应用程序时,我收到了相同的错误消息。我通过检查清单文件中的 targetSDKVersion 解决了我的问题。使用“22”而不是“23”作为 targetSDKVersion 解决了它。(见下文)
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="22" />
I also checked the build.gradle files for compile version and targetSDKversion:
我还检查了 build.gradle 文件的编译版本和 targetSDKversion:
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
}
Hope this will help you. However, this is just a short term workaround for now, I hope that we will get some feedback from metaio though.
希望这会帮助你。然而,这只是目前的短期解决方法,我希望我们能从 metaio 得到一些反馈。
Regards, christin
问候,克里斯汀
回答by christin
I received feedback from metaio's SDK team. They say that this issue cannot be easily solved by metaio, as it is related to the FFMpeg library. We would have to hope that an update of FFMpeg would fix the issue. I assume that we have to wait for such an update and to exchange the library files in the app.
我收到了来自 metaio 的 SDK 团队的反馈。他们说这个问题不能通过 metaio 轻易解决,因为它与 FFMpeg 库有关。我们不得不希望 FFMpeg 的更新能够解决这个问题。我假设我们必须等待这样的更新并在应用程序中交换库文件。
I have not yet looked for a FFMpeg developer contact forum to make enquiries or to notify a bug. Do you know one by accident?
我还没有寻找 FFMpeg 开发人员联系论坛来进行查询或通知错误。你是偶然认识的吗?
Best regrads, christin
最好的毕业生,克里斯汀
回答by Anirudh
Previous versions of Android would warn if asked to load a shared library with text relocations:
如果要求加载带有文本重定位的共享库,以前版本的 Android 会发出警告:
"libfoo.so has text relocations. This is wasting memory and prevents security hardening. Please fix.".
“libfoo.so 有文本重定位。这会浪费内存并阻止安全加固。请修复。”。
Despite this, the OS will load the library anyway. Marshmallow rejects library if your app's target SDK version is >= 23. System no longer logs this because it assumes that your app will log the dlopen(3) failure itself, and include the text from dlerror(3) which does explain the problem. Unfortunately, lots of apps seem to catch and hide the UnsatisfiedLinkError throw by System.loadLibrary
in this case, often leaving no clue that the library failed to load until you try to invoke one of your native methods and the VM complains that it's not present.
尽管如此,操作系统还是会加载库。如果您的应用程序的目标 SDK 版本 >= 23,Marshmallow 将拒绝库。系统不再记录此信息,因为它假定您的应用程序将记录 dlopen(3) 故障本身,并包含 dlerror(3) 中的文本,该文本可以解释问题。不幸的是,UnsatisfiedLinkError throw by System.loadLibrary
在这种情况下,许多应用程序似乎捕获并隐藏了,通常不会留下库加载失败的线索,直到您尝试调用您的本机方法之一并且 VM 抱怨它不存在。
You can use the command-line scanelf tool to check for text relocations. You can find advice on the subject on the internet; for example https://wiki.gentoo.org/wiki/Hardened/Textrels_Guideis a useful guide.
您可以使用命令行 scanelf 工具检查文本重定位。您可以在互联网上找到有关该主题的建议;例如https://wiki.gentoo.org/wiki/Hardened/Textrels_Guide是一个有用的指南。
回答by AReallyGoodName
OK I've got this working here even with targetSDK 23 set.
好的,即使设置了 targetSDK 23,我也在这里工作。
For me and my branch the five files that required patching were
对我和我的分支来说,需要修补的五个文件是
libavcodec\arm\fft_fixed_neon.S
libavcodec\arm\fft_neon.S
libavcodec\arm\fft_vfp.S
libavcodec\arm\mlpdsp_armv5te.S
libutil\arm\asm.S
I took the latest from https://github.com/FFmpeg/FFmpeg
我从https://github.com/FFmpeg/FFmpeg 获取了最新的
You will also need HAVE_SECTION_DATA_REL_RO declared somewhere in your build for the macro in asm.S to use the dynamic relocations option.
您还需要在构建中的某处声明 HAVE_SECTION_DATA_REL_RO,以便 asm.S 中的宏使用动态重定位选项。
回答by thiagolr
You can check if your shared lbirary has text relocations by doing this:
您可以通过执行以下操作来检查您的共享图书馆是否具有文本重定位:
readelf -a path/to/yourlib.so | grep TEXTREL
If it has text relocations, it will show you something like this:
如果它有文本重定位,它会显示如下内容:
0x00000016 (TEXTREL) 0x0
If this is the case, you may recompile your shared library with the latest NDK versionavailable:
如果是这种情况,您可以使用最新的 NDK 版本重新编译共享库:
ndk-build -B -j 8
And if you check it again, the grep command will return nothing.
如果再次检查,grep 命令将不会返回任何内容。
回答by Ozzz
After a long time struggling and trying to compile FFmpeg in different ways, I found the solution. Make sure to compile FFmpeg with the --disable-asm flag. This will make sure that FFmpeg wouldn't have text relocations and won't crash when compiling against Android M (SDK 23)
经过长时间的挣扎并尝试以不同的方式编译 FFmpeg,我找到了解决方案。确保使用 --disable-asm 标志编译 FFmpeg。这将确保 FFmpeg 在针对 Android M (SDK 23) 编译时不会有文本重定位并且不会崩溃
To make sure it worked, you can use readelf as mentioned above.
为了确保它有效,您可以使用上面提到的 readelf。
Cheers
干杯