Page 1 of 1

problem building x64 executable [solved]

Posted: Wed Sep 26, 2007 6:33 am
by os64dev
hi all,

When using the linkerscript posted below i get the folowing error messages:
obj/core/core.co: In function `crt::main()':
core.cc:(.text+0x115): relocation truncated to fit: R_X86_64_32 against `.rodata
.str1.1'
lib/libc.lib(printf.co): In function `printf(char const*, ...)':
printf.cc:(.text+0x534): relocation truncated to fit: R_X86_64_32 against `.text
If i compile with the -fPIC compiler flag everything works. My question:
Can somebody explian to me why this is and how to solve it. I don't want to have position independant code for every executable.

i have build a cross compiler btw.

os64dev

Code: Select all

OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
ENTRY (_ZN3crt4mainEv)

SECTIONS
{
    . = 0xFFFFFFFFC0000000;

    code_base = .;

    .text :
    {   *(.text*);
    }

    code_end = .;


    . = ALIGN (0x1000); /* align on a 4 KiB page */

    rodata_base = .;

    .rodata :
    {   *(.rdata*);
        *(.rodata*);

        ctors_base = ALIGN (0x08);
            *(.ctors*);
        ctors_end = ALIGN (0x08); 

        dtors_base = ALIGN (0x08);
            *(.dtors*);
        dtors_end = ALIGN (0x08); 
    }

    rodata_end = .;


    . = ALIGN (0x1000); /* align on a 4 KiB page */

    rwinit_base = .;

    .rwinit :
    {   *(.data*);
        *(.rwdata*);
    }

    rwinit_end = .;

    rwdata_base = .;

    .rwdata :
    {   bss_base = ALIGN (0x08);
        *(.bss*);
        bss_end = ALIGN (0x08); 
        *(COMMON*);
        
    }

    rwdata_end = ALIGN (0x10); /* align on a realmode segment boundry */

    /DISCARD/ : { *(.comment .note .eh_frame .symtab) }
}

Posted: Wed Sep 26, 2007 9:37 am
by bluecode

problem building x64 executable [solved]

Posted: Wed Sep 26, 2007 12:26 pm
by os64dev
thanx, should read the manual better ;-)