cfenollosa / os-tutorial

How to create an OS from scratch
BSD 3-Clause "New" or "Revised" License
26.94k stars 3.27k forks source link

Linker script #184

Open 0xmatia opened 3 years ago

0xmatia commented 3 years ago

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

algorithmx51 commented 3 years ago

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

0xmatia commented 3 years ago

Where do I define these parameters in this project?

algorithmx51 commented 3 years ago

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