title: Shared library using static gnutls library has text relocations
body: <p><strong>Problem:</strong> I need to port gnutls to Android to be used in a shared library (say library A) I'm using in my Android application.</p>
  
  <p><strong>What I've tried:</strong> I've modified the <a href="http://git.infradead.org/users/dwmw2/openconnect.git/blob/HEAD:/android/Makefile" rel="nofollow noreferrer">make file</a> for openconnect to generate a .a static library file for gnutls and its dependencies (libgmp, libnettle and libhogweed), I used them to build static libraries in my Android project and referenced them in the shared library A. Code builds and installs fine but on M+ devices I get the following error at runtime:</p>
  
  <pre><code>java.lang.UnsatisfiedLinkError: dlopen failed: libA.so: has text relocations
  </code></pre>
  
  <p>I've tried to pass the <code>-fPIC</code> flag when building the static libraries (.a files) and when building the libA.so file with no luck, I can always see TEXTREL entries in libA.so file. I'm sure it is due to the those new static libraries since I was using libA before with no issues.
  Other thing I tried: tried building gnutls as a shared library, the generated libA.so now had no text relocations but would still fail to load at runtime because the gnutls so files have a version (e.g libgnutls.so.3.0) and Android does not support versioned libraries.</p>
  
  <p><strong>Specific question:</strong> How can I either: 1.Build gnutls as a static library without text relocations or 2. Build it as a shared library with no soname?</p>
  
  <p>Edit: I see the same <a href="http://lists.infradead.org/pipermail/openconnect-devel/2016-March/003534.html" rel="nofollow noreferrer">question</a> asked on the openconnect mailing list but no clear way on how to "fix the TEXTRELs in the native code first".</p>
  
  <p>I have seen other answers for problems with text relocations like this <a href="https://stackoverflow.com/questions/32346402/libavcodec-so-has-text-relocations">question</a> and <a href="https://stackoverflow.com/questions/20141538/mylib-so-has-text-relocations-this-is-wasting-memory-and-is-a-security-risk-pl">this</a> question but that didn't help since I'm using the latest NDK build and passing the PIC flag already</p>