Fixed
Created: Jun 7, 2016
Updated: Sep 8, 2018
Resolved Date: Jun 15, 2016
Found In Version: 7.0.0.15
Fix Version: 7.0.0.17
Severity: Standard
Applicable for: Wind River Linux 7
Component/s: Kernel
Our customer tried to execute statically linked 32-bit binary on Linux arm64.
They used fsl-ls1043 bsp, and enabled following CONFIG_COMPAT kernel config.
--------------------
config COMPAT
bool "Kernel support for 32-bit EL0"
depends on !ARM64_64K_PAGES
select COMPAT_BINFMT_ELF
select HAVE_UID16
select OLD_SIGSUSPEND3
select COMPAT_OLD_SIGACTION
help
This option enables support for a 32-bit EL0 running under a 64-bit
kernel at EL1. AArch32-specific components such as system calls,
the user helper functions, VFP support and the ptrace interface are
handled appropriately by the kernel.
If you want to execute 32-bit userspace applications, say Y.
--------------------
They compiled a test program with "-static" option using toolchain which included in Freescale_Linux_LS1043A_SDK_v0.5. They copied that binary to the target and executed it. Then the program failed with segmentation fault. The log is as follows:
--------------------
# ./test32
Internal error: : 8a000000 [#1] SMP
Modules linked in:
CPU: 1 PID: 283 Comm: test32 Not tainted 3.14.39ltsi-rt37-WR7.0.0.15_preempt-rt #4
task: ffffffc019f40280 ti: ffffffc017028000 task.ti: ffffffc017028000
PC is at 0x1fa2f9001ba1
LR is at ret_fast_syscall+0x0/0x80
pc : [<00001fa2f9001ba1>] lr : [<ffffffc00008425c>] pstate: 80000145
sp : ffffffc01702bed0
x29: 0000000000000000 x28: ffffffc017028000
x27: ffffffc00008d000 x26: 000000000000007a
x25: 0000000000000182 x24: 0000000000000011
x23: 0000000060000030 x22: 00000000000329d6
x21: ffffffffffffffff x20: 0000000000000000
x19: 0000000000400000 x18: 0000000000000000
x17: 0000000000000000 x16: f9001fa2f9001ba1
x15: 0000000000000000 x14: 000000000001a937
x13: 00000000ffec01d4 x12: 000000000006c760
x11: 0000000000000000 x10: 0000000000000000
x9 : 0000000000000000 x8 : 0000000000000000
x7 : 000000000000007a x6 : 000000000006b4c8
x5 : 0000000000008c6d x4 : 00000000ffec0504
x3 : 0000000000000000 x2 : 0000000000008000
x1 : 0000000000000001 x0 : 00000000ffec0218
Process test32 (pid: 283, stack limit = 0xffffffc017028058)
Stack: (0xffffffc01702bed0 to 0xffffffc01702c000)
bec0: ffec0218 00000000 00000001 00000000
bee0: 00008000 00000000 00000000 00000000 ffec0504 00000000 00008c6d 00000000
bf00: 0006b4c8 00000000 0000007a 00000000 00000000 00000000 00000000 00000000
bf20: 00000000 00000000 00000000 00000000 0006c760 00000000 ffec01d4 00000000
bf40: 0001a937 00000000 00000000 00000000 00000000 00000000 00000000 00000000
bf60: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
bf80: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
bfa0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
bfc0: 00000000 00000000 00000000 00000000 000329d6 00000000 60000030 00000000
bfe0: ffec0218 00000000 0000007a 00000000 fdffffff ffffffff ffffffff ffffffff
Call trace:
Code: bad PC value
---[ end trace 2062a5e2787f2367 ]---
Segmentation fault
--------------------
Although fsl-ls1043 bsp doesn't have 32-bit library or dynamic linker, I think statically linked program could be executed with CONFIG_COMPAT kernel config.
So,
1. Is it supported to execute statically linked 32-bit binary on WRL7 arm64?
2. Are there any other settings to execute statically linked 32-bit binary other than CONFIG_COMPAT?
1. Create a project:
$ /opt/wrlinux-7/wrlinux-7/wrlinux/configure --enable-board=fsl-ls1043 --enable-kernel=preempt-rt --enable-rootfs=glibc-std-sato
2. Enable CONFIG_COMPAT kernel config and make the project
$ make -C build linux-windriver.menuconfig
$ make
3. Compile following test program with "-static" option:
----------
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
int main(int argc, char **argv)
{
printf("%s: Hi!!\n",argv[0]);
return 0;
}
----------
4. Execute the test program on the target
As an aside, I tried qemuarm64 bsp instead of fsl-ls1043, then the same result was gotten.
In step 3, I used toolchain provided with Ubuntu 15.10(arm-linux-gnueabi-gcc).