Skip to content

Commit

Permalink
android: Build libraries --with-pic
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
cernekee committed Feb 12, 2018
1 parent a486d42 commit b31ca89
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion android/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit b31ca89

Please sign in to comment.