Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Executable format not compatible with WSL #75

Closed
zephyrbot opened this issue May 28, 2017 · 4 comments
Closed

Executable format not compatible with WSL #75

zephyrbot opened this issue May 28, 2017 · 4 comments

Comments

@zephyrbot
Copy link
Collaborator

zephyrbot commented May 28, 2017

Reported by Carles Cufi:

After installing the SDK (successfully) on WSL, when running the SDK toolchain files on WSL (Windows Subsystem for Linux) I get an "Exec format error". Given that WSL executes all binaries from the standard Ubuntu repositories, this makes me think that there must be something off with the way those executables are compiled. This prevents people from building Zephyr using the SDK on Windows 10.

Note that Zephyr builds fine if one uses CROSS_COMPILE=arm-none-eabi- and install gcc-arm-none-eabi with apt.

Potential related issues:

microsoft/WSL#711
microsoft/WSL#330
microsoft/WSL#1048

{code}
carles@SNIH:/mnt/c/Users/Carles/src/zephyr$ file /home/carles/prog/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/arm-zephyr-eabi/arm-zephyr-eabi-gcc
/home/carles/prog/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/arm-zephyr-eabi/arm-zephyr-eabi-gcc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.2.0, BuildID[sha1]=9f928685659780cd09c44c365a1b8c11fd5d1be8, stripped

carles@SNIH:/mnt/c/Users/Carles/src/zephyr$ /home/carles/prog/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/arm-zephyr-eabi/arm-zephyr-eabi-gcc
bash: /home/carles/prog/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/arm-zephyr-eabi/arm-zephyr-eabi-gcc: cannot execute binary file: Exec format error
{code}

file for the standard arm-none-eabi-gcc from Ubuntu:

{code}
carles@SNIH:/mnt/c/Users/Carles/src/zephyr$ file /usr/bin/arm-none-eabi-gcc
/usr/bin/arm-none-eabi-gcc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=58660f7f21c0b34bfeb673d57d22475c51ea5f4e, stripped
{code}

ELF headers for the standard arm-none-eabi-gcc from Ubuntu which runs correctly:

{code}
carles@SNIH:/mnt/c/Users/Carles/src/zephyr$ readelf -n /usr/bin/arm-none-eabi-gcc

Displaying notes found at file offset 0x0000028c with length 0x00000020:
Owner Data size Description
GNU 0x00000010 NT_GNU_ABI_TAG (ABI version tag)
OS: Linux, ABI: 2.6.24

Displaying notes found at file offset 0x000002ac with length 0x00000024:
Owner Data size Description
GNU 0x00000014 NT_GNU_BUILD_ID (unique build ID bitstring)
Build ID: 58660f7f21c0b34bfeb673d57d22475c51ea5f4e

carles@SNIH:/mnt/c/Users/Carles/src/zephyr$ readelf -e /usr/bin/arm-none-eabi-gcc
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: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x405b98
Start of program headers: 64 (bytes into file)
Start of section headers: 732888 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 10
Size of section headers: 64 (bytes)
Number of section headers: 31
Section header string table index: 30

Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .interp PROGBITS 0000000000400270 00000270
000000000000001c 0000000000000000 A 0 0 1
[ 2] .note.ABI-tag NOTE 000000000040028c 0000028c
0000000000000020 0000000000000000 A 0 0 4
[ 3] .note.gnu.build-i NOTE 00000000004002ac 000002ac
0000000000000024 0000000000000000 A 0 0 4
[ 4] .gnu.hash GNU_HASH 00000000004002d0 000002d0
0000000000000044 0000000000000000 A 5 0 8
[ 5] .dynsym DYNSYM 0000000000400318 00000318
0000000000000c30 0000000000000018 A 6 1 8
[ 6] .dynstr STRTAB 0000000000400f48 00000f48
00000000000004e5 0000000000000000 A 0 0 1
[ 7] .gnu.version VERSYM 000000000040142e 0000142e
0000000000000104 0000000000000002 A 5 0 2
[ 8] .gnu.version_r VERNEED 0000000000401538 00001538
00000000000000a0 0000000000000000 A 6 2 8
[ 9] .rela.dyn RELA 00000000004015d8 000015d8
00000000000000a8 0000000000000018 A 5 0 8
[10] .rela.plt RELA 0000000000401680 00001680
0000000000000b70 0000000000000018 A 5 12 8
[11] .init PROGBITS 00000000004021f0 000021f0
000000000000001a 0000000000000000 AX 0 0 4
[12] .plt PROGBITS 0000000000402210 00002210
00000000000007b0 0000000000000010 AX 0 0 16
[13] .text PROGBITS 00000000004029c0 000029c0
000000000005b35a 0000000000000000 AX 0 0 16
[14] .fini PROGBITS 000000000045dd1c 0005dd1c
0000000000000009 0000000000000000 AX 0 0 4
[15] .rodata PROGBITS 000000000045dd40 0005dd40
00000000000442a4 0000000000000000 A 0 0 32
[16] .eh_frame_hdr PROGBITS 00000000004a1fe4 000a1fe4
00000000000020fc 0000000000000000 A 0 0 4
[17] .eh_frame PROGBITS 00000000004a40e0 000a40e0
000000000000c1f4 0000000000000000 A 0 0 8
[18] .gcc_except_table PROGBITS 00000000004b02d4 000b02d4
0000000000000108 0000000000000000 A 0 0 4
[19] .tbss NOBITS 00000000006b0e70 000b0e70
0000000000000010 0000000000000000 WAT 0 0 8
[20] .init_array INIT_ARRAY 00000000006b0e70 000b0e70
0000000000000010 0000000000000000 WA 0 0 8
[21] .fini_array FINI_ARRAY 00000000006b0e80 000b0e80
0000000000000008 0000000000000000 WA 0 0 8
[22] .jcr PROGBITS 00000000006b0e88 000b0e88
0000000000000008 0000000000000000 WA 0 0 8
[23] .data.rel.ro PROGBITS 00000000006b0ea0 000b0ea0
0000000000000f58 0000000000000000 WA 0 0 32
[24] .dynamic DYNAMIC 00000000006b1df8 000b1df8
00000000000001e0 0000000000000010 WA 6 0 8
[25] .got PROGBITS 00000000006b1fd8 000b1fd8
0000000000000018 0000000000000008 WA 0 0 8
[26] .got.plt PROGBITS 00000000006b2000 000b2000
00000000000003e8 0000000000000008 WA 0 0 8
[27] .data PROGBITS 00000000006b2400 000b2400
0000000000000998 0000000000000000 WA 0 0 32
[28] .bss NOBITS 00000000006b2da0 000b2d98
0000000000013bb0 0000000000000000 WA 0 0 32
[29] .gnu_debuglink PROGBITS 0000000000000000 000b2d98
000000000000001c 0000000000000000 0 0 1
[30] .shstrtab STRTAB 0000000000000000 000b2db4
0000000000000123 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), l (large)
I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)

Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
PHDR 0x0000000000000040 0x0000000000400040 0x0000000000400040
0x0000000000000230 0x0000000000000230 R E 8
INTERP 0x0000000000000270 0x0000000000400270 0x0000000000400270
0x000000000000001c 0x000000000000001c R 1
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
LOAD 0x0000000000000000 0x0000000000400000 0x0000000000400000
0x00000000000b03dc 0x00000000000b03dc R E 200000
LOAD 0x00000000000b0e70 0x00000000006b0e70 0x00000000006b0e70
0x0000000000001f28 0x0000000000015ae0 RW 200000
DYNAMIC 0x00000000000b1df8 0x00000000006b1df8 0x00000000006b1df8
0x00000000000001e0 0x00000000000001e0 RW 8
NOTE 0x000000000000028c 0x000000000040028c 0x000000000040028c
0x0000000000000044 0x0000000000000044 R 4
TLS 0x00000000000b0e70 0x00000000006b0e70 0x00000000006b0e70
0x0000000000000000 0x0000000000000010 R 8
GNU_EH_FRAME 0x00000000000a1fe4 0x00000000004a1fe4 0x00000000004a1fe4
0x00000000000020fc 0x00000000000020fc R 4
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 10
GNU_RELRO 0x00000000000b0e70 0x00000000006b0e70 0x00000000006b0e70
0x0000000000001190 0x0000000000001190 R 1

Section to Segment mapping:
Segment Sections...
00
01 .interp
02 .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame .gcc_except_table
03 .init_array .fini_array .jcr .data.rel.ro .dynamic .got .got.plt .data .bss
04 .dynamic
05 .note.ABI-tag .note.gnu.build-id
06 .tbss
07 .eh_frame_hdr
08
09 .init_array .fini_array .jcr .data.rel.ro .dynamic .got
{code}

ELF headers for the SDK executable that does not execute:

{code}
carles@SNIH:/mnt/c/Users/Carles/src/zephyr$ readelf -n /home/carles/prog/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/arm-zephyr-eabi/arm-zephyr-eabi-gcc

Displaying notes found at file offset 0x00001238 with length 0x00000020:
Owner Data size Description
GNU 0x00000010 NT_GNU_ABI_TAG (ABI version tag)
OS: Linux, ABI: 3.2.0

Displaying notes found at file offset 0x00001258 with length 0x00000024:
Owner Data size Description
GNU 0x00000014 NT_GNU_BUILD_ID (unique build ID bitstring)
Build ID: 9f928685659780cd09c44c365a1b8c11fd5d1be8

carles@SNIH:/mnt/c/Users/Carles/src/zephyr$ readelf -e /home/carles/prog/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/arm-zephyr-eabi/arm-zephyr-eabi-gcc
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: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x4047e0
Start of program headers: 64 (bytes into file)
Start of section headers: 848208 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 9
Size of section headers: 64 (bytes)
Number of section headers: 30
Section header string table index: 29

Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .interp PROGBITS 0000000000400238 00000238
0000000000001000 0000000000000000 A 0 0 1
[ 2] .note.ABI-tag NOTE 0000000000401238 00001238
0000000000000020 0000000000000000 A 0 0 4
[ 3] .note.gnu.build-i NOTE 0000000000401258 00001258
0000000000000024 0000000000000000 A 0 0 4
[ 4] .hash HASH 0000000000401280 00001280
00000000000006cc 0000000000000004 A 5 0 8
[ 5] .dynsym DYNSYM 0000000000401950 00001950
0000000000000de0 0000000000000018 A 6 1 8
[ 6] .dynstr STRTAB 0000000000402730 00002730
000000000000058c 0000000000000000 A 0 0 1
[ 7] .gnu.version VERSYM 0000000000402cbc 00002cbc
0000000000000128 0000000000000002 A 5 0 2
[ 8] .gnu.version_r VERNEED 0000000000402de8 00002de8
00000000000000b0 0000000000000000 A 6 3 8
[ 9] .rela.dyn RELA 0000000000402e98 00002e98
0000000000000090 0000000000000018 A 5 0 8
[10] .rela.plt RELA 0000000000402f28 00002f28
0000000000000c60 0000000000000018 AI 5 24 8
[11] .init PROGBITS 0000000000403b88 00003b88
0000000000000017 0000000000000000 AX 0 0 4
[12] .plt PROGBITS 0000000000403ba0 00003ba0
0000000000000850 0000000000000010 AX 0 0 16
[13] .text PROGBITS 00000000004043f0 000043f0
0000000000060399 0000000000000000 AX 0 0 16
[14] .fini PROGBITS 000000000046478c 0006478c
0000000000000009 0000000000000000 AX 0 0 4
[15] .rodata PROGBITS 00000000004647a0 000647a0
0000000000052f50 0000000000000000 A 0 0 32
[16] .eh_frame_hdr PROGBITS 00000000004b76f0 000b76f0
00000000000021c4 0000000000000000 A 0 0 4
[17] .eh_frame PROGBITS 00000000004b98b8 000b98b8
000000000000dc94 0000000000000000 A 0 0 8
[18] .init_array INIT_ARRAY 00000000006c7d68 000c7d68
0000000000000028 0000000000000008 WA 0 0 8
[19] .fini_array FINI_ARRAY 00000000006c7d90 000c7d90
0000000000000008 0000000000000008 WA 0 0 8
[20] .jcr PROGBITS 00000000006c7d98 000c7d98
0000000000000008 0000000000000000 WA 0 0 8
[21] .data.rel.ro PROGBITS 00000000006c7da0 000c7da0
0000000000000028 0000000000000000 WA 0 0 32
[22] .dynamic DYNAMIC 00000000006c7dc8 000c7dc8
0000000000000210 0000000000000010 WA 6 0 8
[23] .got PROGBITS 00000000006c7fd8 000c7fd8
0000000000000010 0000000000000008 WA 0 0 8
[24] .got.plt PROGBITS 00000000006c8000 000c8000
0000000000000438 0000000000000008 WA 0 0 8
[25] .data PROGBITS 00000000006c8440 000c8440
0000000000000bc8 0000000000000000 WA 0 0 32
[26] .gccrelocprefix PROGBITS 00000000006c9020 000c9020
0000000000006000 0000000000000000 WA 0 0 32
[27] .bss NOBITS 00000000006cf020 000cf020
0000000000002448 0000000000000000 WA 0 0 32
[28] .gnu_debuglink PROGBITS 0000000000000000 000cf020
0000000000000018 0000000000000000 0 0 1
[29] .shstrtab STRTAB 0000000000000000 000cf038
0000000000000117 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), l (large)
I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)

Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
PHDR 0x0000000000000040 0x0000000000400040 0x0000000000400040
0x00000000000001f8 0x00000000000001f8 R E 8
INTERP 0x0000000000000238 0x0000000000400238 0x0000000000400238
0x0000000000001000 0x0000000000001000 R 1
[Requesting program interpreter: /home/carles/prog/zephyr-sdk/sysroots/x86_64-pokysdk-linux/lib/ld-linux-x86-64.so.2]
LOAD 0x0000000000000000 0x0000000000400000 0x0000000000400000
0x00000000000c754c 0x00000000000c754c R E 200000
LOAD 0x00000000000c7d68 0x00000000006c7d68 0x00000000006c7d68
0x00000000000072b8 0x0000000000009700 RW 200000
DYNAMIC 0x00000000000c7dc8 0x00000000006c7dc8 0x00000000006c7dc8
0x0000000000000210 0x0000000000000210 RW 8
NOTE 0x0000000000001238 0x0000000000401238 0x0000000000401238
0x0000000000000044 0x0000000000000044 R 4
GNU_EH_FRAME 0x00000000000b76f0 0x00000000004b76f0 0x00000000004b76f0
0x00000000000021c4 0x00000000000021c4 R 4
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 10
GNU_RELRO 0x00000000000c7d68 0x00000000006c7d68 0x00000000006c7d68
0x0000000000000298 0x0000000000000298 R 1

Section to Segment mapping:
Segment Sections...
00
01 .interp
02 .interp .note.ABI-tag .note.gnu.build-id .hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame
03 .init_array .fini_array .jcr .data.rel.ro .dynamic .got .got.plt .data .gccrelocprefix .bss
04 .dynamic
05 .note.ABI-tag .note.gnu.build-id
06 .eh_frame_hdr
07
08 .init_array .fini_array .jcr .data.rel.ro .dynamic .got
{code}

(Imported from Jira SDK-58)

@zephyrbot
Copy link
Collaborator Author

by Carles Cufi:

Main difference I see is ABI being 3.2.0 on the SDK executables vs 2.6.24 on the Ubuntu ones.

@zephyrbot
Copy link
Collaborator Author

by Juro Bystricky:

Based on (bottom of the page)
microsoft/WSL#1048

this issue has been fixed in Windows 10 build 15002.
(That is my understanding)

@zephyrbot
Copy link
Collaborator Author

by Carles Cufi:

Juro Bystricky right, and I just checked and I'm running an older build. I will ask IT to update my Windows 10, retest and then close this if applicable.

@zephyrbot
Copy link
Collaborator Author

by Carles Cufi:

Tested with 15063 and the issue is indeed resolved. Will close this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant