link.ld Example Explanation

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.
Locked
User avatar
Nathan
Member
Member
Posts: 201
Joined: Sun Jul 19, 2009 1:48 pm
Location: Brazil
Contact:

link.ld Example Explanation

Post by Nathan »

Hello,
I've compiled successfully the FreeBASIC Barebones Example, there we have a example to use with ld called link.ld:

Code: Select all

OUTPUT_FORMAT("elf32-i386")
ENTRY (loader)

SECTIONS{
    . = 0x00100000;

    .text :{
        KERNEL_START = .;

        *(.text)
    }

    .rodata ALIGN (0x1000) : {
        *(.rodata)
        _CTORS = .;
        *(.ctors)
        _CTORS_END = .;       
    }

    .data ALIGN (0x1000) : {
        *(.data)
    }

    .bss : {
        SBSS = .;
        *(COMMON)
        *(.bss)
        EBSS = .;

        KERNEL_END = .;
    }
}
But as I've only used ld one time that my friend sent me a source to be compiled and I need to use ld, but someone could please explain me line-by-line about this script?

Best Regards,
Nathan Paulino Campos
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: link.ld Example Explanation

Post by Combuster »

"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Nathan
Member
Member
Posts: 201
Joined: Sun Jul 19, 2009 1:48 pm
Location: Brazil
Contact:

Re: link.ld Example Explanation

Post by Nathan »

I will use google before asking stupid questions! :D
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: link.ld Example Explanation

Post by qw »

Here's the place to be: http://sourceware.org/binutils/docs/ld/index.html.

Nice avatar.
Locked