elf troubles..

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

elf troubles..

Post by os64dev »

I am trying to build a kernel in the elf format but the file seems to become huge > 1MiB. I've searched the wiki and such but it still gives problems.

here is my linker script:

Code: Select all

SECTIONS
{
    . = 0xFFFFFFFFC0000000;
    /***************************************************************************
    * This block contains the executable code, its information is used by the  *
    * program loader to allocate and setup executable read-only pages.         *
    ***************************************************************************/

    code_base = .;

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

    code_end = .;


    . = ALIGN (0x1000);                              /* align on a 4 KiB page */
    /***************************************************************************
    * This block contains the non-changeable data, its information is used by  *
    * the program loader to allocate and setup non-executable read-only pages. *
    ***************************************************************************/

    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 */
    /***************************************************************************
    * This block contains the initialised data, its information is used by the *
    * program loader to allocate and setup non-executable read-write pages.    *
    ***************************************************************************/

    rwinit_base = .;

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

    rwinit_end = .;

    /***************************************************************************
    * This block contains the non-initialised data, its information is used by *
    * the program loader to allocate and setup non-executable read-write pages.*
    ***************************************************************************/

    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) }
}
it seems that it produces some info after 1 MiB in the output file.
Oh yeah it all gcc++ based .
Author of COBOS
User avatar
AndrewAPrice
Member
Member
Posts: 2309
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post by AndrewAPrice »

Code: Select all

    . = 0xFFFFFFFFC0000000; 
I'm not a linker expert, but is this aligning your code to this position? Or creating a pointer to it? If it's aligning it, then it could be filling blank data up to this point.
My OS is Perception.
User avatar
bluecode
Member
Member
Posts: 202
Joined: Wed Nov 17, 2004 12:00 am
Location: Germany
Contact:

Post by bluecode »

Use

Code: Select all

    . = 0xFFFFFFFFC0000000 + SIZEOF_HEADERS; 
Dump ld will align your code to 1 MiB (within the elf file) for some stupid reason.
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post by os64dev »

thanx for the replies. I found out that i did not call ld with the -nostartfiles commandline option. After changing this it worked fine. @Bluecode it seems that your option would also have worked because SIZEOF_HEADERS is linked to the startfiles.
Author of COBOS
Post Reply