title: Calling an assembly function from another file
body: <p>I have the following code to compute square of a number which works perfectly:</p>
  
  <pre><code>        .section .data
  
          .section .text
  
          .globl _start
          .globl square
  
  _start:
          pushl $10
  
          call square
          addl $4, %esp
  
          movl %eax, %ebx
          movl $1, %eax
          int $0x80
  
          .type square,@function
  
  square:
          pushl %ebp
          movl %esp, %ebp
          movl 8(%ebp), %eax
  
          imull %eax, %eax
  
  end_square:
          movl %ebp, %esp
          popl %ebp
          ret     
  </code></pre>
  
  <p>I want to call the function <code>square</code> from another file named <code>square_test.s</code>. This is my attempt:</p>
  
  <pre><code>        .section .data
  
          .section .text
  
          .globl _start
  
  _start:
  
          pushl $12
          call square
          addl $4, %esp
  
          movl %eax, %ebx
          movl $1, %eax
          int $0x80
  </code></pre>
  
  <p>But when linking it throws me this error:</p>
  
  <pre><code>$ as --32 square_test.s -o square_test.o
  $ as --32 square.s -o square.o
  $ ld -m elf_i386 square.o square_test.o -o square_test
  square_test.o: In function `_start':
  (.text+0x0): multiple definition of `_start'
  square.o:(.text+0x0): first defined here
  </code></pre>
  
  <p>How should I fix this ?</p>