bug#81211: #81211 31.0.90; Android build fails with current Java compilers

Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email protected]>
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
Johan Myréen <[email protected]> writes:

> In the emacs/exec directory the linker is passed an obscure option
> -Ttext=0x2000000000, which I presume is trying to say that the text
> segment should be placed starting at address 0x200000000 (?):
>
> /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang -c -O -g loader-aarch64.s -o loader-aarch64.o
> clang: warning: argument unused during compilation: '-O' [-Wunused-command-line-argume
> nt]
> /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang -o loader -nostdlib -nostartfiles -static -
> Wl,-Ttext=0x2000000000 loader-aarch64.o
>
> I don't know for which compiler/linker combination the Makefile is
> generated for, since, as far as I can tell, both lld and GNU ld use
> the -T switch to specify a linker script file.

-Ttext is distinct from -T.  -Ttext=0xN is equivalent to specifying the
address provided as the `--section-start' for the text segment, the
effect of which should only be to set the base address of the section
metadata.

> Anyway, the outcome of the linker invocation above results in a huge
> binary file consisting mostly of null bytes. The size of the file is
> 137436859800 bytes, which happens to be a little less than
> 0x200000000. Likewise the file libloader.so, which is included in the
> Android Emacs installer file is 137 GB in size; examining an older
> emacs.apk file reveals that the correct size is about 7.3 kB.
>
> I'm hoping for someone who knows more about the Android Emacs build
> process to step forward and clarify what went wrong, and how to
> correct it.

Which version of the NDK is this?  I cannot reproduce this problem with
NDK r28, which (for aarch64) generates such a loader executable:

ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           AArch64
  Version:                           0x1
  Entry point address:               0x2000000000
  Start of program headers:          64 (bytes into file)
  Start of section headers:          19232 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         4
  Size of section headers:           64 (bytes)
  Number of section headers:         11
  Section header string table index: 9
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.