title: ARM Linux executable mysteriously runs on x86_64
body: <p>I'm using the Docker container (<code>thewtex/cross-compiler-linux-armv7</code>) to cross-compile a simple "Hello World" Linux user space C program on an <code>x86_64</code> system. The target system is a ARMv7 embedded system (in particular a Kobo Aura HD e-reader with stock firmware).</p>
  
  <p>The source code of the program (<code>hello_world.c</code>) is as follows</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(int argc, char *argv[]) {
      printf("Hello World!\n");
      return 0;
  }
  </code></pre>
  
  <p>Unexpectedly, I can execute the resulting executable on the host system:</p>
  
  <pre><code>andreas@andreas-pc:~/tmp/test$ uname -a &amp;&amp; ./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!
  </code></pre>
  
  <p>as well as on the target device</p>
  
  <pre><code>[root@(none) onboard]# uname -a &amp;&amp; ./hello 
  Linux (none) 2.6.35.3-850-gbc67621+ #1038 PREEMPT Thu Apr 25 15:48:22 CST 2013 armv7l GNU/Linux
  Hello World!
  </code></pre>
  
  <p>Is there any explanation for this?</p>
  
  <hr>
  
  <p>For reference, I invoke the compiler using the following set of commands</p>
  
  
  
  <pre class="lang-sh prettyprint-override"><code>docker run thewtex/cross-compiler-linux-armv7 &gt; ./dockcross.sh
  chmod +x dockcross.sh
  </code></pre>
  
  <p>For some reason the generated shell script is buggy, I manually have to replace <code>/cross-compiler-base/cross-compiler-linux-armv7/</code> and <code>/:build/:build:z/</code> in <code>dockcross.sh</code>. Now I run</p>
  
  <pre class="lang-sh prettyprint-override"><code>./dockcross.sh arm-linux-gnueabihf-cc hello_world.c -static -o hello
  </code></pre>
  
  <p><code>file</code> returns the following information about the resulting <code>hello</code> executable</p>
  
  <pre class="lang-sh prettyprint-override"><code>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
  </code></pre>