Search code examples
assemblycygwinld

linker outputs 'relocation truncated to fit: R_X86_64_32' when trying to link yasm assembled program


I have a simple asm file:

$ cat my.asm
    segment .text
    global _start

_start:
        mov eax,1
        mov ebx,5
        int 0x80

Assembling with yasm works ok:

$ yasm -f elf64 -g dwarf2  -l my.lst my.asm

Linking returns some output:

$ ld -o my my.o
my.o:(.debug_aranges+0x6): relocation truncated to fit: R_X86_64_32 against `.debug_info'
my.o:(.debug_info+0x6): relocation truncated to fit: R_X86_64_32 against `.debug_abbrev'
my.o:(.debug_info+0xc): relocation truncated to fit: R_X86_64_32 against `.debug_line'

However, no executable is created.

My environment is:

$ yasm --version
yasm 1.2.0

$ ld --version
GNU ld (GNU Binutils) 2.23.52.20130604

$ uname -a
CYGWIN_NT-6.1 MYHOST 1.7.25(0.270/5/3) 2013-08-31 20:37 x86_64 Cygwin

The code snippet and assembling/linking steps came from the book: Introduction to 64bit Intel Assembly Language Programming

Any pointers as to why this is not working will be appreciated.


Solution

  • Cygwin binaries that use Linux system calls cannot run on windows - even through cygwin. See this answer for more info.