title: How do i get rid of call __x86.get_pc_thunk.ax
body: <p>I tried to compile and convert a very simple C program  to assembly language. </p>
  
  <p>I am using Ubuntu and the OS type is 64 bit. </p>
  
  <p>This is the C Program.</p>
  
  <pre><code>void add();
  
  int main() { 
  add();
  return 0;
  }
  </code></pre>
  
  <p>if i use gcc -S -m32 -fno-asynchronous-unwind-tables -o simple.S simple.c this is how my assembly source code File should look like:</p>
  
  <pre><code>.file   "main1.c"
  .text
  .globl main
  .type   main, @function
  main:
  pushl   %ebp
  movl    %esp, %ebp
  andl    $-16, %esp
  call    add
  movl    $0, %eax
  movl    %ebp, %esp
  popl    %ebp
  ret
  .size   main, .-main
  .ident  "GCC: (Debian 4.4.5-8) 4.4.5" // this part should say Ubuntu instead of Debian
  .section    .note.GNU-stack,"",@progbits
  </code></pre>
  
  <p>but instead it looks like this:</p>
  
  <pre><code>.file   "main0.c"
  .text
  .globl  main
  .type   main, @function
  main:
  leal    4(%esp), %ecx
  andl    $-16, %esp
  pushl   -4(%ecx)
  pushl   %ebp
  movl    %esp, %ebp
  pushl   %ebx
  pushl   %ecx
  call    __x86.get_pc_thunk.ax
  addl    $_GLOBAL_OFFSET_TABLE_, %eax
  movl    %eax, %ebx
  call    add@PLT
  movl    $0, %eax
  popl    %ecx
  popl    %ebx
  popl    %ebp
  leal    -4(%ecx), %esp
  ret
  .size   main, .-main
  .section        
  
  .text.__x86.get_pc_thunk.ax,"axG",@progbits,__x86.get_pc_thunk.ax,comdat
  .globl  __x86.get_pc_thunk.ax
  .hidden __x86.get_pc_thunk.ax
  .type   __x86.get_pc_thunk.ax, @function
  __x86.get_pc_thunk.ax:
  movl    (%esp), %eax
  ret
  .ident  "GCC: (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406"
  .section    .note.GNU-stack,"",@progbits
  </code></pre>
  
  <p>At my University they told me to use the Flag -m32 if I am using a 64 bit Linux version. Can somebody tell me what I am doing wrong? 
  Am I even using the correct Flag?</p>
  
  <p>edit after -fno-pie</p>
  
  <pre><code>.file   "main0.c"
  .text
  .globl  main
  .type   main, @function
  main:
  leal    4(%esp), %ecx
  andl    $-16, %esp
  pushl   -4(%ecx)
  pushl   %ebp
  movl    %esp, %ebp
  pushl   %ecx
  subl    $4, %esp
  call    add
  movl    $0, %eax
  addl    $4, %esp
  popl    %ecx
  popl    %ebp
  leal    -4(%ecx), %esp
  ret
  .size   main, .-main
  .ident  "GCC: (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406"
  .section    .note.GNU-stack,"",@progbits
  </code></pre>
  
  <p>it looks better but it's not exactly the same.
  for example what does leal mean? </p>