title: Segmentation fault .data
body: <p>I have a little question about "segmentation-fault" issue, but I can find any answer.</p>
  
  <p>I can deactivate the stack protection at the gcc compilation, with options <code>[-fno-stack-protector] -z execstack</code>:</p>
  
  <pre><code>GNU_STACK 0x0000000000000000  **RWE**    10
  --&gt;
  GNU_STACK 0x0000000000000000  **RW**     10
  </code></pre>
  
  <p><em>But</em>: For me, the <code>.data</code> section <em>is not</em> in the <code>GNU_STACK</code> segment! (Am I wrong?)</p>
  
  <p>So, I don't understand why in one case I can execute a shellcode which is in the <code>.data</code> section, and I can't in another!</p>
  
  <p>If it can help:</p>
  
  <pre><code>JC@ubuntu:~$ cat testShellcode2.c
  
      char bytecode[] = "\x48\x31\xc0\x48\x31\xff\x48\x31\xf6\x48\x31\xd2\x52\xeb\x15\x48\x8b\x3c\x24\x48\x89\xe6\xb0\x3b\x0f\x05\x48\x31\xc0\x48\x31\xff\xb0\x3c\x0f\x05\xe8\xe6\xff\xff\xff\x2f\x62\x69\x6e\x2f\x73\x68";
  
      int main(){
          int (*ret)() ;
          ret = (int(*)()) bytecode;
          ret();
      }
  
  
  JC@ubuntu:~$ cp testShellcode2.c testShellcode3.c
  
  JC@ubuntu:~$ gcc -fno-stack-protector -z execstack testShellcode2.c -o testShellcode2
  
  JC@ubuntu:~$ gcc testShellcode3.c -o testShellcode3
  
  JC@ubuntu:~$ ./testShellcode2
  $ exit
  
  JC@ubuntu:~$ ./testShellcode3
  Segmentation fault (core dumped)
  
  JC@ubuntu:~$ readelf -a testShellcode2 &gt; elf2
  
  JC@ubuntu:~$ readelf -a testShellcode3 &gt; elf3
  
  JC@ubuntu:~$ diff elf2 elf3
  
                    0x0000000000000000 0x0000000000000000  RWE    10
  
                    0x0000000000000000 0x0000000000000000  RW     10
  </code></pre>