From: Kevin Cernekee Date: Mon, 29 Jan 2018 00:56:18 +0000 (-0800) Subject: android: Build libraries --with-pic X-Git-Tag: v8.00~126^2~4 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=b31ca89f298644c271e49addeea6bbedc34b079c;p=users%2Fdwmw2%2Fopenconnect.git android: Build libraries --with-pic 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 --- diff --git a/android/Makefile b/android/Makefile index bb922dfd..414bf300 100644 --- a/android/Makefile +++ b/android/Makefile @@ -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 \