title: Compile code to raw binary
body: <p>I'm trying to compile my code into raw binary and as suggested by other SO posts (like <a href="https://stackoverflow.com/a/1647405/363949">this</a> and <a href="https://stackoverflow.com/a/3615546/363949">this</a>) I tried objdump:</p>
  
  <pre><code>$ gcc -c foo.c
  $ objcopy -O binary foo.o foo.bin
  </code></pre>
  
  <p>Then I tried to make sure if this is valid:</p>
  
  <pre><code>$ objdump -d foo.o
  
  foo.o:     file format elf64-x86-64
  
  
  Disassembly of section .text:
  
  0000000000000000 &lt;main&gt;:
     0:   55                      push   %rbp
     1:   48 89 e5                mov    %rsp,%rbp
     4:   48 83 ec 10             sub    $0x10,%rsp
     8:   89 7d fc                mov    %edi,-0x4(%rbp)
     b:   48 89 75 f0             mov    %rsi,-0x10(%rbp)
     f:   bf 00 00 00 00          mov    $0x0,%edi
    14:   b8 00 00 00 00          mov    $0x0,%eax
    19:   e8 00 00 00 00          callq  1e &lt;main+0x1e&gt;
    1e:   b8 00 00 00 00          mov    $0x0,%eax
    23:   c9                      leaveq 
    24:   c3                      ret
  
  $ hexdump -C foo.bin
  
  00000000  14 00 00 00 00 00 00 00  01 7a 52 00 01 78 10 01  |.........zR..x..|
  00000010  1b 0c 07 08 90 01 00 00  1c 00 00 00 1c 00 00 00  |................|
  00000020  00 00 00 00 25 00 00 00  00 41 0e 10 86 02 43 0d  |....%....A....C.|
  00000030  06 60 0c 07 08 00 00 00                           |.`......|
  00000038
  </code></pre>
  
  <p>Evidently something is wrong. I checked this with the results of a gcc cross-compilation, with much the same obviously incorrect results.</p>