]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
android: Build libraries --with-pic
authorKevin Cernekee <cernekee@gmail.com>
Mon, 29 Jan 2018 00:56:18 +0000 (16:56 -0800)
committerKevin Cernekee <cernekee@gmail.com>
Mon, 12 Feb 2018 03:39:14 +0000 (19:39 -0800)
Recent Android OS releases have become stricter about TEXTRELs in
native code.  When built without -DPIC, a few of the libgmp assembly
files generate problematic code sequences:

    $ scanelf -qT arm-linux-androideabi/openconnect/.libs/libopenconnect.so
    libopenconnect.so: (memory/data?) [0x23F320] in (optimized out: previous $a.0) [0x23F2B8]
    [...]

    0023f2b8 <__gmpn_modexact_1c_odd>:
      23f2b8:       e92d0030        push    {r4, r5}
      23f2bc:       e59f405c        ldr     r4, [pc, #92]   ; 23f320 <__gmpn_modexact_1c_odd+0x68>
    [...]
      23f320:       003171b8        .word   0x003171b8

In this case, adjusting the address at 23f320 would require making .text
writable, which Android does not want to do.

The solution is to specify --with-pic which causes the LEA macro
($GMP/mpn/arm/arm-defs.m4) to embed a PC-relative address into the code,
avoiding the issue.

Tested on ARM + x86.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
android/Makefile

index bb922dfdc3c6912a9f55f00f59a6545ca2f34490..414bf300d10614a9eb80d6acb5b641476dd30aa1 100644 (file)
@@ -47,7 +47,7 @@ MAKEINSTALL=$(MAKE) INSTALL=$(TOPDIR)/install_symlink.sh
 FETCH=$(TOPDIR)/fetch.sh
 
 CONFIGURE_ARGS := --host=$(TRIPLET) --prefix=$(OC_SYSROOT) \
-                 --disable-shared --enable-static \
+                 --disable-shared --enable-static --with-pic \
                  CC=$(TRIPLET)-clang CFLAGS="$(EXTRA_CFLAGS)"
 
 SOURCE_LIST = $(LIBXML2_SRC)/configure $(GMP_SRC)/configure \