title: Segmentation Fault while replacing a character x86 NASM on Linux
body: <p>I'm getting a segmentation fault after writing <code>mov [gtt+4], byte '&gt;'</code> where my variable is defined as <code>gtt: db &quot;I'm ! than 10&quot;</code>.<br><br>
  I feel like it might be an error when assembling the program.<br>
  I'm using the commands: <code>nasm -f elf file.asm -o file.o</code>, <code>ld -m elf_i386 file.o -o file</code>
  I have tried to use elf32 rather than elf but it doesn't make a difference.<br><br>
  The purpose of my program is to loop 2 times, multiplying whatever is in ebx by 2 each time. Afterwards, it will compare if ecx &gt; 10 and displaying the corresponding string. I'm trying to get it to replace the &quot;!&quot; with either &quot;&lt;&quot; or &quot;&gt;&quot;.</p>
  <p>I'm using Ubuntu, and I'm working in x86 assembly.
  Here is my full code snippet:</p>
  <pre><code>
  section .data:
      starti: db &quot;Starting value: 1&quot;, 0x0a
      startil equ $-starti
  
      gtt: db &quot;I'm &gt; than 10!&quot;, 0x0a
      gttml equ $-gtt 
  
  section .text:
  _start:
      mov eax, 4
      mov ebx, 1
      mov ecx, starti
      mov edx, startil
      int 0x80
  
      mov ebx, 1  ; Start value!  
      mov ecx, 2  ; Number of iterations  
  
  
  label:
      add ebx, ebx    ; Add 2*ebx
      dec ecx     ; ecx -= 1
      cmp ecx, 0  ; If ecx &gt; 0, loop again
      jg label
      
      cmp ebx, 10 ; If cbx &gt; 10, jump to gtt-g
      jg gttg
  
      mov [gtt+4], byte '&lt;'
      mov eax, 4  ; If cbx &lt; 10, output &lt;
      mov ebx, 1
      mov ecx, gtt
      mov edx, gttml
      int 0x80
  
      mov eax, 1  ; Exit gracefully
      mov ebx, 0
      int 0x80
      
  gttg: 
      mov [gtt+4], byte '&gt;'
      mov eax, 4  ; Display gtt
      mov ebx, 1
      mov ecx, gtt
      mov edx, gttml
      int 0x80
      
      mov eax, 1  ; Exit gracefully
      mov ebx, 0
      int 0x80
  </code></pre>
  <p><strong>Fix</strong><br>
  Thanks to Jester for this, &quot;you must not use colons after section names, they are not labels. As it is, the colon is included in the name and hence the assembler doesn't recognize them as standard sections and doesn't apply the expected attributes meaning your data is read only. TL;DR: use section .data and section .text without a trailing&quot;.</p>