title: NASM 'fatal: No section for index 2 offset 0 found' on Mac OS X Yosemite
body: <p>This is my first time programming in assembly for the Mac, and keep getting some strange errors that I haven't had much luck with googling-wise. So far, I'm just trying to print "Hello, World!" onto the terminal. Here is my code: </p>
  
  <pre><code>global _main
  
  
  section .text
  
  _main:
      mov rax, 0x20000004
      mov rdi, 1
      mov rsi, msg
      mov rdx, msg.len
      syscall
  
      mov rax, 0x20000001
      mov rdi, 0
      syscall
  
  
  section .data
  
  msg:    db  "Hello, World!", 10
  .len:   equ $ - msg
  </code></pre>
  
  <p>Whenever I run this code, I use the command <code>nasm -f macho64 print.asm</code>. By the way, <code>nasm -v</code> prints <code>NASM version 2.11.08 compiled on Mar 10 2015</code>. When I use the command above, NASM gives this output:</p>
  
  <pre><code>print.asm:9: fatal: No section for index 2 offset 0 found
  </code></pre>
  
  <p>I'm stumped and would like any help. Thanks!</p>