title: Undefined reference to memcpy in ARM-NONE-EABI link chain
body: <p>I'm compiling and linking a bare metal applicacation. In this case is simple standard c code (did not write it myself, but I read it thoroughly and it does not seem to need any libraries) for AES encryption. </p>
  
  <p>My problem comes when linking. This is the linker command used. </p>
  
  <pre><code>arm-none-eabi-ld boot_and_link/startup.o drivers/gpio.o  ../programs/aes_e/aes.o ../programs/aes_e/aes_test.o ../programs/aes_e/key_expansion.o -nostartfiles -T boot_and_link/linker.ld -o ../programs/aes_e/aes_e.elf -L/usr/lib/gcc/arm-none-eabi/4.8/armv6-m -lgcc
  </code></pre>
  
  <p>I've written my own linker script and my own startup code. I get three errors like this:</p>
  
  <pre><code>.../programs/aes_e/aes_test.c:41: undefined reference to `memcpy'
  </code></pre>
  
  <p>From three lines like this:</p>
  
  <pre><code>unsigned char key[16] =
  { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
  </code></pre>
  
  <p>Within the main function. I can make these errors go away by simply cutting those three lines and placing them outside of the main function. This tells me that the line above inside the main function requires copying the data from one section of memory to another. (Please correct me if I'm wrong). Now I've read that memcpy is defined in libgcc.a. I've even grepped for it (in the directory for the armv6-m architecture) and I got a match (Binary file ./libgcc.a matches as a result of the grep command).</p>
  
  <p>So my question becomes why does this error persist? Do I need to link with some other library? </p>
  
  <p>Just to clarify there are NO includes in any of my source files except to other files that I wrote myself (no string.hn stddefs.h or any of those).</p>