Ich benutze einen Docker-Container (thewtex/cross-compiler-linux-armv7
), um eine einfache "Hello World" Linux-User-Space-C-Programm auf einem Fedora 23 x86_64
System zu kompilieren. Das Zielsystem ist ein ARMv7-Embedded-System (insbesondere ein Kobo Aura HD E-Reader mit Bestandsfirmware).ARM Linux ausführbare Datei läuft auf x86_64
Der Quellcode des Programms (hello_world.c
) ist wie
#include <stdio.h>
int main(int argc, char *argv[]) {
printf("Hello World!\n");
return 0;
}
folgt I den Compiler mit dem folgenden Satz von Befehlen
docker run thewtex/cross-compiler-linux-armv7 > ./dockcross.sh
chmod +x dockcross.sh
aus irgendeinem Grund die erzeugte Shell-Skript ist aufzurufen Buggy, muss ich manuell /cross-compiler-base/cross-compiler-linux-armv7/
und /:build/:build:z/
in dockcross.sh
ersetzen. Jetzt laufe ich
./dockcross.sh arm-linux-gnueabihf-cc hello_world.c -static -o hello
file
gibt die folgenden Informationen über die resultierenden hello
ausführbare
hello: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=317a9ea164931f614b24e98dec743050e2d7f900, not stripped
Unerwarteterweise kann ich die ausführbare Datei auf dem Host-System ausführen:
[email protected]:~/tmp/test$ uname -a && ./hello
Linux andreas-pc 4.5.5-201.fc23.x86_64 #1 SMP Sat May 21 15:29:49 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
Hello World!
sowie auf dem Zielgerät
[[email protected](none) onboard]# uname -a && ./hello
Linux (none) 2.6.35.3-850-gbc67621+ #1038 PREEMPT Thu Apr 25 15:48:22 CST 2013 armv7l GNU/Linux
Hello World!
Gibt es eine Erklärung dafür?
Möglicherweise jemand konfiguriert [binfmt_misc] (https://en.m.wikipedia.org/wiki/Binfmt_misc) für Sie und legte es so fest, dass arm ausführbare Programme qemu ausführen. –
Danke, binfmt_misc ist in der Tat der Mechanismus, der diese Magie ermöglicht. Ich werde eine Antwort auf diese Frage schreiben. –