McZ wrote:
if someone could be nice to explain what the linker-script does (or give me a link to a good tutorial or something) it would be good, I havn't found anyone that I understand correct yet.
Which means your idea of what a linker does is fuzzy, and your idea of how an executable is constructed is virtually non-existent.
Every object file (C code turned into machine code but not yet linked together) is constructed of several sections. For example, executable code in *.text, constants in *.rodata, initialized variables in *.data, global variables in *COMMON, zero-initialized memory in *.bss.
If you followed Pype's link into the FAQ, you'll see a pattern here.
What those sections are depends on the object file format (ELF, COFF, PE, etc.). The FAQ assumes ELF.
The linker script tells the linker how to put the individual object files' sections together into a single binary: *.text and *.rodata into *.text, *.data into *.data, *COMMON and *.bss into *.bss. Again, this pattern is dependent on the binary file format (which, again, we assume is ELF).
The rest is telling the linker what symbol designates the entry point (_loader), and where the resulting binary will be loaded to (0x00100000) so it can adapt any memory references.
Voila, your object files have been linked together into a binary.
Usually, when compiling application software, you don't specify a linker script, you use the default one - which links in the C runtime (crt0.o) and loads of auxiliary stuff you wouldn't want in your kernel image. That's why you have to juggle linker scripts when linking a kernel.
That's what our example script does, which is sufficient to get you started.
As to what
else you can do in a linker script, refer to the ld manual (part of binutils,
http://www.gnu.org/software/binutils/manual/). As to object file format details, refer to the individual format descriptions, or reverse-engineer 'em with objdump if you feel adventurous.