title: Why data and stack segments are executable?
body: <p>I have just noticed that my simple program has its data and stack segments executable.
  I saw it in /proc/[pid]/maps, and simple code confirmed it.</p>
  
  <p>For example:</p>
  
  <pre><code>; prog.asm
  section .data
      code:   db 0xCC    ;int3
  
  section .text
  global _start
  _start:
      jmp    code
  
      mov    rax, 60    ; sys_exit
      mov    rdi, 0
      syscall
  </code></pre>
  
  <p>then</p>
  
  <pre><code>nasm -f elf64 prog.asm
  ld -o prog prog.o
  ./prog
  </code></pre>
  
  <p>causes prog to execute int3 instruction.</p>
  
  <p>Programs written in C and built with gcc have their data, stack and heap non-executable, so why those written in assembly behave in a different manner?</p>