title: Cannot compile nasm program
body: <p>Trying to compile this code:</p>
  
  <pre><code>global main
  
  extern printf
  
  [section .data]
      fmtStr: db "Input string", 0xA, 0
  
  [section .text]
      main:
          push rbp
          push fmtStr
          call printf
          pop rbp
          ret
  </code></pre>
  
  <p>First step goes well:</p>
  
  <blockquote>
    <p>nasm -f elf64 printf.asm -o printf64.o</p>
  </blockquote>
  
  <p>But gcc fails:</p>
  
  <blockquote>
    <p>gcc printf64.o -o printf64             </p>
    
    <p>/bin/ld: printf64.o: relocation R_X86_64_32S against `.data' can not be used when making a shared object; recompile with -fPIC</p>
    
    <p>/bin/ld: final link failed: Nonrepresentable section on output
    collect2: error: ld returned 1 exit status</p>
  </blockquote>
  
  <p>I have </p>
  
  <blockquote>
    <p>Linux 4.14.8-1-ARCH x86_64</p>
    
    <p>gcc (GCC) 7.2.1 20171128</p>
    
    <p>GNU ld (GNU Binutils) 2.29.1</p>
  </blockquote>