title: Cygwin: Relocation truncated to fit R_X86_64_32S against '.data'
body: <p>I was recently trying to compile the "Find a Maximum Value" program from the book "Programming from the Ground Up". Since I'm using Windows, I compile the assembly file with Cygwin. However, I get the following errors:<br/></p>
  
  <pre><code>/tmp/ccuamKmO.o:fake:(.text+0xc): relocation truncated to fit: R_X86_64_32S against `.data'
  /tmp/ccuamKmO.o:fake:(.text+0x1d): relocation truncated to fit: R_X86_64_32S against `.data'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p><br/>
  It's probably some silly error and I really can't recognise it.
  This is the code for the program: <br/></p>
  
  <pre><code>.section .data
      data_items: 
          .long 3, 67, 34, 222, 45, 75, 54, 34, 44, 33, 22, 11, 66, 0
  
  .section .text
      .globl main
  
  main:
      jmp find_largest
    ret_find_largest:
  
      ret
  
  /* 
   * %edi - Holds the index of the item being examined
   * %ebx - Largest item found
   * %eax - Current item
   */
  find_largest:
      movl $0, %edi
      movl data_items(,%edi,4), %eax /* load eax with first item */
      movl %eax, %ebx
  
    start_loop:
      cmpl $0, %eax
      je loop_exit
      incl %edi
      movl data_items(,%edi,4), %eax
      cmpl %ebx, %eax
      jle start_loop
      movl %eax, %ebx
      jmp start_loop
  
    loop_exit:
      jmp ret_find_largest
  </code></pre>