Closed han-k59 closed 5 months ago
At moment I understand that a shared object is the same as a pie executable. So that is no longer a problem. However the interpreter for Android is wrongly defined as libdl.so. It should be /system/bin/linker64 or /system/bin/linker for 32 bit:
This is what is reported in Linux after entering: file yourprogram: yourprogram: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter libdl.so, BuildID[sha1]=8eeee3c498f7728fe5428122b4acb179362e7bc3, stripped
The interpreter can be corrected using the patchelf program as follows:
patchelf --set-interpreter /system/bin/linker64 ./yourprogram
This results in:
yourprogram: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /system/bin/linker64, BuildID[sha1]=2bf966cbb671b53c38504d838ff2d4c6b4979095, stripped
The options -Cg -k-pie -k-znow are not required. Default for Android?
The outstanding question is now how to get the correct Android interpreter without using patchelf.
I will close this issue and raise a new one for this interpreter problem
I have Fpcupdeluxe installed. I want to cross compile from Linux to Android pie executable.
Compiling a Hello Word program to Linux using options -k-pie -k-znow -Cg gives the following Linux executable:
file test2 test2: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, with debug_info, not stripped
Changing the platform to Android gives the following result:
ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter libdl.so, BuildID[sha1]=9eab5a4e162e001f4892880a899c0843f5cea6eb, with debug_info, not stripped
So a shared object instead of the pie executable.
With only option -Cg-, I can get an Android executable but it is not Pie, so it doesn't work for Android 5+. Note the option -Cg-. test2: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter libdl.so, BuildID[sha1]=79cf6dff7bf31d286eaed661e4e9dc02dda7df79, with debug_info, not stripped
How can I cross compile to an Android pie executable? Or is this caused by a problem with the cross compiler?
I have posted the same problem at the Lazarus forum: https://forum.lazarus.freepascal.org/index.php/topic,67692.0.html
Han