master a9e3adbaea3: Enable compiling Emacs for Android <= 8.1 with NDK r30

Po Lu via Mailing list for Emacs changes <[email protected]>
Newsgroups gmane.emacs.diffs
Message-ID <[email protected]>
branch: master
commit a9e3adbaea36f37d293e23f62944f7147e2f579f
Author: Po Lu <[email protected]>
Commit: Po Lu <[email protected]>

    Enable compiling Emacs for Android <= 8.1 with NDK r30
    
    * exec/configure.ac (exec_cv_ld_supports_rosegment): Detect
    whether ld supports --rosegment.
    If so, specify it in order that the executable header may not be
    combined with .text so as to produce excessively large loader
    executables.  (bug#81211)
---
 exec/configure.ac | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/exec/configure.ac b/exec/configure.ac
index 81780359904..b2bd089d6f6 100644
--- a/exec/configure.ac
+++ b/exec/configure.ac
@@ -477,6 +477,35 @@ _ACEOF
    exec_loader=loader-mips64el.s], [*],
   [AC_MSG_ERROR([Please port libexec to $host])])
 
+# Test whether the linker supports `-Wl,--rosegment'.  Recent versions
+# of the Android NDK forbid the linker to place executable code in a
+# separate PT_LOAD segment on older systems by enabling `--no-rosegment'
+# in the machine specifications:
+#
+# https://reviews.llvm.org/D95166
+#
+# Which occasions the text segment to be combined with the executable
+# header, which is loaded at a much lower base address (e.g.,
+# 0x200000-0x2000000000), to produce an outsized executable containing
+# as many bytes as the difference between the virtual addresses of the
+# start and the end of such data.  This must be disabled.  (bug#81211)
+
+AC_CACHE_CHECK([whether ld supports --rosegment],
+  [exec_cv_ld_supports_rosegment],
+  [new_loaderflags="$LOADERFLAGS $LDPREFIX--rosegment"
+   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int _start, __start;]],[[]])],
+  [exec_cv_ld_supports_rosegment=no
+   $LD -o conftest$EXEEXT $new_loaderflags conftest.$OBJEXT \
+     >&AS_MESSAGE_LOG_FD 2>&1				    \
+     && exec_cv_ld_supports_rosegment=yes],
+  [exec_cv_ld_supports_rosegment=unknown])])
+AS_CASE([$exec_cv_ld_supports_rosegment],
+  [yes],
+  [LOADERFLAGS="$LOADERFLAGS $LDPREFIX--rosegment"],
+  [unknown],
+  [AC_MSG_WARN([configure could not ascertain whether $LDPREFIX--rosegment was supported by the linker.
+An excessively large `loader' binary may be produced in consequence of this failure.])])
+
 AC_SUBST([DADDI_BROKEN])
 
 MIPS_N32=$exec_cv_mips_nabi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.