problem building x64 executable [solved]

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

problem building x64 executable [solved]

Post 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) }
}
Last edited by os64dev on Wed Sep 26, 2007 12:28 pm, edited 1 time in total.
Author of COBOS
User avatar
bluecode
Member
Member
Posts: 202
Joined: Wed Nov 17, 2004 12:00 am
Location: Germany
Contact:

Post by bluecode »

User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

problem building x64 executable [solved]

Post by os64dev »

thanx, should read the manual better ;-)
Author of COBOS
Post Reply