GMP Shared Libraries include Text Relocations for some Architectures

Michael Arpin marpin at unicoi.com
Thu May 18 19:37:21 UTC 2017


Hello,

I was unsure if this would be considered a bug so I decided to come here
first in case I was missing something. An Android application I am working
on requires the use of GMP. Therefore I am including pre-built GMP shared
library objects into the project. The libraries I am using, for
convenience, are pre-built for Android and can be found at
https://github.com/Rupan/gmp for reference.

Compiling the Android application with a "compileSdkVersion 22" on Android
7 (Nougat) results in the system presenting the warning "Detected problems
with app native libraries (please consult log for detail): libgmp.so: text
relocations". If the "compileSdkVersion" is increase to 23 or above, the
warning changes to a FATAL ERROR, preventing the app from running.

It seems newer versions of Android are disallowing libraries that include
text relocations within them. Doing research shows that a GCC compiler
flag, -fPIC, can be used to remove text relocations when compiling. Further
research showed that GMP shared libraries should use the -fPIC compiler
flag by default. After checking which pre-built shared libraries I was
using had text relocations, I noticed some of the shared libraries did have
text relocations and some did not. Continuing my research showed -fPIC is
unable to remove all text relocations from some architecture builds.
However, this last bit I could never find official proof, only word of
mouth so perhaps I am wrong.

I need to be able to include GMP shared libraries into my Android app and
keep including them even after updating my Android SDK version in the
future. Does anyone have more information on this situation? Am I missing
something? What are my options moving forward?

Thanks for reading,
Michael


More information about the gmp-discuss mailing list