Page 1 of 1

Linkers

Posted: Fri Aug 18, 2006 3:24 am
by OS
Hello,
Where to start learning linkers and how to write a linking script?
Thanks.

Re:Linkers

Posted: Fri Aug 18, 2006 3:55 am
by paulbarker
If you're using a GNU toolchain:

Code: Select all

info ld
Or go to www.gnu.org and search for binutils.

If not, please tell us which linker you are using...

Re:Linkers

Posted: Fri Aug 18, 2006 5:13 am
by Pype.Clicker
or check the FAQ. You might have a good bootstrap :P

<edit> just added HowLinkersWork to the FAQ, just in case you're missing an introduction to the subject.

For the rest, the "linker scripts" section of "info ld" should do the trick, really ...

Re:Linkers

Posted: Fri Aug 18, 2006 11:38 am
by OS
Thanks for your reply with usefull info.
Can I use:

Code: Select all

$ nasm -f elf kernel.asm
$ ld -s -o kernel kernel.o
to produce my excutable kernel with out writting a linkscript?

Pype.Clicker, its grub bootloader :)

Re:Linkers

Posted: Fri Aug 18, 2006 12:07 pm
by paulbarker
Why not try it and see what happens? Don't be afraid of playing around as long as you are testing using an emulator or dedicated machine (be careful if testing on a machine which has valuable data).

There are 2 options you do want though: "-nostdlib" and "-e (entry function)". Check the docs, think, and you should understand why.