title: Segmentation fault assembly i386:x86_64
body: <p>I'm working on i386:x86_64 and I'm writing a simple program to start a shell. Bellow is my assembly.</p>
  
  <pre><code>.section .data
  .section .text
  .globl _start
  
  _start:
      xor %rax, %rax
      mov $70, %al
      xor %rbx, %rbx
      xor %rcx, %rcx
      int $0x80
  
      jmp ender
  
  starter:
      pop %rbx
      xor %rax, %rax
      mov %al, 0x07(%rbx)
      mov %rbx, 0x08(%rbx)
      mov %rax, 0x0c(%rbx)
      mov $11, %al
      lea 0x08(%rbx), %rcx
      lea 0x0c(%rbx), %rdx
      int $0x80
  
  ender:
      call starter
      .string "/bin/sh"
  </code></pre>
  
  <p>The problem is that I keep getting a segmentation fault. When I use objdump -D my_prog the output is this ...</p>
  
  <p>Disassembly of section .text:</p>
  
  <pre><code>0000000000400078 &lt;_start&gt;:
    400078:   48 31 c0                xor    %rax,%rax
    40007b:   b0 46                   mov    $0x46,%al
    40007d:   48 31 db                xor    %rbx,%rbx
    400080:   48 31 c9                xor    %rcx,%rcx
    400083:   cd 80                   int    $0x80
    400085:   eb 1b                   jmp    4000a2 &lt;ender&gt;
  
  0000000000400087 &lt;starter&gt;:
    400087:   5b                      pop    %rbx
    400088:   48 31 c0                xor    %rax,%rax
    40008b:   88 43 07                mov    %al,0x7(%rbx)
    40008e:   48 89 5b 08             mov    %rbx,0x8(%rbx)
    400092:   48 89 43 0c             mov    %rax,0xc(%rbx)
    400096:   b0 0b                   mov    $0xb,%al
    400098:   48 8d 4b 08             lea    0x8(%rbx),%rcx
    40009c:   48 8d 53 0c             lea    0xc(%rbx),%rdx
    4000a0:   cd 80                   int    $0x80
  
  00000000004000a2 &lt;ender&gt;:
    4000a2:   e8 e0 ff ff ff          callq  400087 &lt;starter&gt;
    4000a7:   2f                      (bad)  
    4000a8:   62                      (bad)  
    4000a9:   69                      .byte 0x69
    4000aa:   6e                      outsb  %ds:(%rsi),(%dx)
    4000ab:   2f                      (bad)  
    4000ac:   73 68                   jae    400116 &lt;ender+0x74&gt;
  </code></pre>
  
  <p>I'm going to take guess and say that it is addresses that are marked (bad) which is causing the seg fault. I know this is happening because it wants mem access to mem not allocated to it. I'm not really to sure what I should do. I am running Linux.</p>