title: AS assembler ARM Raspberry PI 3 linking with C libraries?
body: <p>I am learning how to program on my raspberry pi. When i compile I use the <code>as</code> and <code>ld</code> commands to compile and link. I want to link with libc and use malloc but not use <code>gcc</code> as my compiler. I tried linking with /usr/lib/arm-linux-gnueabihf/libc.so</p>
  
  <p>Here is what I typed (edit):</p>
  
  <pre><code>as test.s -o test.o
  ld -o test test.o /usr/lib/arm-linux-gnueabihf/libc.so
  ./test
  </code></pre>
  
  <p>it compiled and linked, but when I try to run it, it says test is not found</p>
  
  <p>Here is <code>test.s</code>:</p>
  
  <pre><code>.global _start
  .extern malloc
  
  _start:
      mov R0, #4
      bl malloc
      mov R0, #0
      mov R7, #1
      svc 0
  .end
  </code></pre>
  
  <p>Is this ok?<br>
  Or do I need to do something more?<br>
  Any help would be appreciated?</p>
  
  <p>EDIT here is what I am doing (don't forget to initialize C if using some of its functions!):</p>
  
  <pre><code>ld -o test /usr/lib/arm-linux-gnueabihf/libc.so test.o -dynamic-linker /lib/ld-linux-armhf.so.3
  </code></pre>