title: Accessing a corrupted shared library
body: <p>Here is the code of <code>cpuid2.s</code>:</p>
  
  <pre><code>#cpuid2.s view the cpuid vendor id string using c library calls
  .section .data
  output:
      .asciz "The processor Vendor ID is '%s'\n"
  
  .section .bss
      .lcomm buffer, 12
  
  .section .text
  .global _start
  _start:
      movl $0, %eax
      cpuid
      movl $buffer, %edi
      movl %ebx, (%edi)
      movl %edx, 4(%edi)
      movl %ecx, 8(%edi)
      push $buffer
      push $output
      call printf
      addl $8, %esp
      push $0
      call exit
  </code></pre>
  
  <p>I assemble, link, and run it as so:</p>
  
  <pre><code>as -o cpuid2.o cpuid2.s
  ld -dynamic-linker /lib/ld-linux.so.2 -o cpuid2 -lc cpuid2.o
  ./cpuid2
  bash: ./cpuid2: Accessing a corrupted shared library
  </code></pre>
  
  <p>I've searched StackOverflow for this error. I found <a href="https://stackoverflow.com/questions/26541955/gnu-assembler-accessing-a-corrupted-shared-library-error">this question</a> which is similar to mine. And I tried the method given by @rasion. Like this:</p>
  
  <pre><code>as -32 -o cpuid2.o cpuid2.s
  ld -melf_i386 -L/lib -lc -o cpuid2 cpuid2.o
  ld: cannot find -lc
  </code></pre>
  
  <p>His answer doesn't solve my problem. I hope someone can help me.</p>
  
  <p>I'm using AT&amp;T syntax with GNU assembler.</p>
  
  <p>My computer has 64 bit Ubuntu 14.04.</p>