title: How to compile baremetal hello_world.c and run it on qemu-system-aarch64?
body: <p>As the title, I want to compile hello_world.c program and run it on qemu-system-aarch64. Here is the program:</p>
  <pre><code>#include &lt;stdio.h&gt;
  int main()
  {
  printf(&quot;hello world!\n&quot;);
  }
  </code></pre>
  <p>from <a href="https://releases.linaro.org/components/toolchain/binaries/latest-7/aarch64-elf/" rel="nofollow noreferrer">https://releases.linaro.org/components/toolchain/binaries/latest-7/aarch64-elf/</a> (this is baremetal directory), I can see these tool chains:</p>
  <pre><code>folder  aarch64-elf -       
  folder  aarch64-linux-gnu   -       
  folder  aarch64_be-elf  -       
  folder  aarch64_be-linux-gnu    -       
  folder  arm-eabi    -       
  folder  arm-linux-gnueabi   -       
  folder  arm-linux-gnueabihf -       
  folder  armeb-eabi  -       
  folder  armeb-linux-gnueabi -       
  folder  armeb-linux-gnueabihf   -       
  folder  armv8l-linux-gnueabihf
  </code></pre>
  <p>So I chose aarch64-elf (is this correct?) and installed it on my ubuntu 16.04 machine and added the bin directory to the path.
  If I just do <code>aarch64-elf-gcc hello_world.c</code> I get undefined reference errors for _exit, _sbrk, _write, _close, _lseek, _read, _fstat, _isatty functions. so I tried adding -spec=aem.ve-specs and it doesn't complain (I'm not sure this is correct).
  and I tried running qemu.</p>
  <pre><code>qemu-system-aarch64 -M virt -cpu cortex-a57 -nographic -smp 1 -m 2048 -kernel a.out
  </code></pre>
  <p>and it doesn't give me any print. What should I change here?</p>