os-tutorial icon indicating copy to clipboard operation
os-tutorial copied to clipboard

Linker script

Open 0xmatia opened this issue 4 years ago • 3 comments

In most projects online you can find a linker script that defines the memory segments of the kernel. My questions are: Do I need one and why does this project doesn't use one? Thanks

0xmatia avatar Sep 22 '20 11:09 0xmatia

a linker script does one thing : define where on memory the segments of the program will be loaded and some attributes like how they are going to be aligned into memory, the size and much more. E.g the .text will load on 0x10000, .data on 0x50000 and so on. It is not necessary, but really useful if needed Edit: basically you can use it to define the linking arguments too, like the output format

algorithmx51 avatar Sep 22 '20 13:09 algorithmx51

Where do I define these parameters in this project?

0xmatia avatar Sep 23 '20 00:09 0xmatia

you include your linker file with -T link.ld eg. i386-elf-ld -T link.ld where link.ld in the name of the linker script file Now in this project i don't think you really need a linker script, except you are facing problems with making the kernel to work

algorithmx51 avatar Sep 23 '20 03:09 algorithmx51