Android Gradle compile so library or run-time the correct workaround for text relocations crashes

Source: Internet
Author: User

1. The so library appears when compiling

This is typically caused by the use of a new version of the NDK compilation, which the new NDK considers warning as error,

Workaround: Add #local_disable_fatal_linker_warnings to Android.mk: = True

The so library compiled by this method cannot run on machines with a target API of more than 23.

2. Android Runtime crash prompt

This is primarily because, starting with API 23, shared objects will not contain text relocation. In other words, the code must be loaded as is, and it cannot be modified. This approach reduces load times and improves security. A common cause of text relocation is the use of a non-locating, independent handwriting assembler.

Solution: 2.1, the third party libraries the word compile-time open-fpic (position independent code) or--enable-pic support, because this reason is mostly caused by assembly language, may also have to open the form of--disable-asm.

2.2, Android.mk plus local_cflags: =-fpic,so Library needs to be able to compile on the new NDK (cannot use 1 resolution)

2.3, use the form of SCANELF-QT libyour.so check so library, refer to this article Https://wiki.gentoo.org/wiki/Hardened/Textrels_Guide

3. Attached

3.1. API23 Android changes for NDK developers

3.2, Http://stackoverflow.com/questions/32346402/libavcodec-so-has-text-relocations

3.3, http://blog.csdn.net/cantus_hjk/article/details/51979635

Android Gradle compile so library or run-time the correct workaround for text relocations crashes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.