title: sys_execve system call from Assembly
body: <p>asm_execve.s:</p>
  
  <pre>
  .section .data
  file_to_run:
  .ascii       "/bin/sh"
  
  .section .text
  .globl main
  
  main:
      pushl %ebp
      movl %esp, %ebp
      subl $0x8, %esp         # array of two pointers. array[0] = file_to_run  array[1] = 0
  
      movl file_to_run, %edi
      movl %edi, -0x4(%ebp)   
      movl $0, -0x8(%ebp)
  
      movl $11, %eax                      # sys_execve
      movl file_to_run, %ebx              # file to execute       
      leal -4(%ebp), %ecx                 # command line parameters
      movl $0, %edx                       # environment block
      int  $0x80              
  
      leave
      ret
  </pre>
  
  <p>makefile:</p>
  
  <pre>
  NAME = asm_execve
  $(NAME) : $(NAME).s
      gcc -o $(NAME) $(NAME).s
  </pre>
  
  <p>Program is executed, but sys_execve is not called:</p>
  
  <pre>
  alex@alex32:~/project$ make
  gcc -o asm_execve asm_execve.s
  alex@alex32:~/project$ ./asm_execve 
  alex@alex32:~/project$ 
  </pre>
  
  <p>Expected output is:</p>
  
  <pre>
  alex@alex32:~/project$ ./asm_execve 
  $ exit
  alex@alex32:~/project$
  </pre>
  
  <p>This Assembly program is supposed to work like the following C code:</p>
  
  <pre>
  char *data[2];
  data[0] = "/bin/sh"; 
  data[1] = NULL;
  execve(data[0], data, NULL);
  </pre>
  
  <p>Something wrong in system call parameters?</p>