title: Debugging Assembly (NASM) using gdb
body: <p>I am trying to debug some Assembly using gdb and I am having some issues. Once I enter gdb, I am unable to add breakpoints, and the file command doesn't seem to work. The exact outputs are at the bottom. I've tried searching for answers but none seem to work. I am running Ubuntu 17.10</p>
  
  <p><strong>main.asm</strong></p>
  
  <pre><code>section .text
  global _start
  _start:
      mov ecx, string
      call printStr
      exit:
      mov eax, 1
      mov ebx, 0
      int 0x80
  
      printStr:
      pusha
      cmp byte [ecx], 0
      je breakPrintStr
      mov eax, 4
      mov ebx, 2
      mov edx, 1
      int 0x80
      add ecx, 1
      jmp printStr
      breakPrintStr:
      popa
      ret
  section .data
      string db 'Hello, World!',0xa,0
  </code></pre>
  
  <p><strong>Makefile</strong></p>
  
  <pre><code>file = main
  compile: $(file).asm Makefile
      nasm -g -f elf -F dwarf $(file).asm
      ld -m elf_i386 -s -o $(file) $(file).o
      rm $(file).o
      chmod +x $(file)
  </code></pre>
  
  <p>Then I launch gdb using</p>
  
  <pre><code>gdb main
  
  (gdb) file main
  </code></pre>
  
  <p>Results in</p>
  
  <pre><code>Reading symbols from main...(no debugging symbols found)...done.
  </code></pre>
  
  <p>And</p>
  
  <pre><code>(gdb) b _global
  </code></pre>
  
  <p>Results in</p>
  
  <pre><code>No symbol table is loaded.  Use the "file" command.
  Make breakpoint pending on future shared library load? (y or [n])
  </code></pre>