title: gcc arm executable "no such file orr directory", wrong dynamic lib
body: <p>I am trying to make a usable setup for gcc-linaro-arm-linux-gnueabihf-4.8-2013.11 on windows.
  Something happens at dynamic link:</p>
  
  <pre><code>$(CC)-gcc   -o test main.c -Wall -lc
  </code></pre>
  
  <p>The program compiles fine, but when deployed to ARM shows:
  "No such file or directory"</p>
  
  <p>Searching the issue, seems that static build works but executable is huge:</p>
  
  <pre><code>$(CC)-gcc   -static -o test main.c -Wall -lc
  </code></pre>
  
  <p>Now I have a VisualGDB toolchain installed that builds (in IDE) with it's own toolchain a similar executable (small, dynamic) that works so I guess this is nothing wrong with my ARM distribution.</p>
  
  <p>Am I missing something or wrong include from gcc-linaro-arm-linux-gnueabihf-4.8-2013.11 ?</p>
  
  <p>Thanks very much in advance,</p>
  
  <p>One more investigation:</p>
  
  <pre><code>file test
  
  working (compiled with VisualGDB toolchain)
  test: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped
  
  mot working (compiled with gcc-linaro-arm-linux-gnueabihf-4.8-2013.11)
  test: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.1.1, BuildID[sha1]=0x13accf06af902cd8b96d85b8a412e1d7822a302b, not stripped
  
  my ARM
  3.8.13
  </code></pre>
  
  <p>I run -readelf (for non working):</p>
  
  <pre><code>Dynamic section at offset 0x474 contains 24 entries:
    Tag        Type                         Name/Value
   0x00000001 (NEEDED)                     Shared library: [libc.so.6]
   0x0000000c (INIT)                       0x82a0
   0x0000000d (FINI)                       0x8434
   0x00000019 (INIT_ARRAY)                 0x10468
   0x0000001b (INIT_ARRAYSZ)               4 (bytes)
   0x0000001a (FINI_ARRAY)                 0x1046c
   0x0000001c (FINI_ARRAYSZ)               4 (bytes)
   0x00000004 (HASH)                       0x8194
   0x00000005 (STRTAB)                     0x820c
   0x00000006 (SYMTAB)                     0x81bc
   0x0000000a (STRSZ)                      65 (bytes)
   0x0000000b (SYMENT)                     16 (bytes)
   0x00000015 (DEBUG)                      0x0
   0x00000003 (PLTGOT)                     0x1055c
   0x00000002 (PLTRELSZ)                   32 (bytes)
   0x00000014 (PLTREL)                     REL
   0x00000017 (JMPREL)                     0x8280
   0x00000011 (REL)                        0x8278
   0x00000012 (RELSZ)                      8 (bytes)
   0x00000013 (RELENT)                     8 (bytes)
   0x6ffffffe (VERNEED)                    0x8258
   0x6fffffff (VERNEEDNUM)                 1
   0x6ffffff0 (VERSYM)                     0x824e
   0x00000000 (NULL)                       0x0
  </code></pre>
  
  <p>and working:</p>
  
  <pre><code>Dynamic section at offset 0x4d0 contains 24 entries:
    Tag        Type                         Name/Value
   0x00000001 (NEEDED)                     Shared library: [libc.so.6]
   0x0000000c (INIT)                       0x8274
   0x0000000d (FINI)                       0x8490
   0x00000019 (INIT_ARRAY)                 0x104c4
   0x0000001b (INIT_ARRAYSZ)               4 (bytes)
   0x0000001a (FINI_ARRAY)                 0x104c8
   0x0000001c (FINI_ARRAYSZ)               4 (bytes)
   0x00000004 (HASH)                       0x8168
   0x00000005 (STRTAB)                     0x81e0
   0x00000006 (SYMTAB)                     0x8190
   0x0000000a (STRSZ)                      65 (bytes)
   0x0000000b (SYMENT)                     16 (bytes)
   0x00000015 (DEBUG)                      0x0
   0x00000003 (PLTGOT)                     0x105b8
   0x00000002 (PLTRELSZ)                   32 (bytes)
   0x00000014 (PLTREL)                     REL
   0x00000017 (JMPREL)                     0x8254
   0x00000011 (REL)                        0x824c
   0x00000012 (RELSZ)                      8 (bytes)
   0x00000013 (RELENT)                     8 (bytes)
   0x6ffffffe (VERNEED)                    0x822c
   0x6fffffff (VERNEEDNUM)                 1
   0x6ffffff0 (VERSYM)                     0x8222
   0x00000000 (NULL)                       0x0
  </code></pre>
  
  <p>strace log:</p>
  
  <pre><code>execve("/usr/bin/test", ["test"], [/* 15 vars */]) = 0
  brk(0)                                  = 0x17000
  uname({sys="Linux", node="beaglebone", ...}) = 0
  mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f8a000
  access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
  open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
  fstat64(3, {st_mode=S_IFREG|0644, st_size=54751, ...}) = 0
  mmap2(NULL, 54751, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6f57000
  close(3)                                = 0
  open("/lib/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
  read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0@\321\0\0004\0\0\0"..., 512) = 512
  fstat64(3, {st_mode=S_IFREG|0644, st_size=1505830, ...}) = 0
  mmap2(NULL, 152384, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6f31000
  mprotect(0xb6f4f000, 28672, PROT_NONE)  = 0
  mmap2(0xb6f56000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1d) = 0                                                                                   xb6f56000
  close(3)                                = 0
  open("/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\210\177\1\0004\0\0\0"..., 512) = 512
  fstat64(3, {st_mode=S_IFREG|0755, st_size=1205468, ...}) = 0
  mmap2(NULL, 1246600, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6e00000
  mprotect(0xb6f24000, 28672, PROT_NONE)  = 0
  mmap2(0xb6f2b000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x123) =                                                                                    0xb6f2b000
  mmap2(0xb6f2e000, 9608, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb                                                                                   6f2e000
  close(3)                                = 0
  mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f89000
  set_tls(0xb6f896d0, 0xb6f89da8, 0xb6f8c058, 0xb6f896d0, 0xb6f8c058) = 0
  mprotect(0xb6f2b000, 8192, PROT_READ)   = 0
  mprotect(0xb6f8b000, 4096, PROT_READ)   = 0
  munmap(0xb6f57000, 54751)               = 0
  brk(0)                                  = 0x17000
  brk(0x38000)                            = 0x38000
  close(1)                                = 0
  close(2)                                = 0
  exit_group(1)                           = ?
  +++ exited with 1 +++
  </code></pre>