【发布时间】:2014-08-25 18:07:45
【问题描述】:
我最近试图从“从头开始编程”一书中编译“找到最大值”程序。由于我使用的是 Windows,因此我使用 Cygwin 编译程序集文件。但是,我收到以下错误:
/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
这可能是一些愚蠢的错误,我真的无法识别。
这是程序的代码:
.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
【问题讨论】:
标签: assembly cygwin linker-errors