Linker script

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.
Post Reply
karim
Posts: 21
Joined: Mon Jun 23, 2025 8:03 pm

Linker script

Post by karim »

the linker script is what tells the linker to arrange the code so that it expects to start at a certain address in RAM, for example 0x1000. After that, the loader comes and actually places the code at that RAM address (0x1000). So it’s basically like a map for the loader, right?
Octocontrabass
Member
Member
Posts: 6245
Joined: Mon Mar 25, 2013 7:01 pm

Re: Linker script

Post by Octocontrabass »

I see you asked this question elsewhere too.

As long as you use a binary format that can store address information in its headers, like ELF or PE, the linker script does indeed work like a map for the loader.

However, if you're using a binary format that doesn't store address information, the loader has no way to know what you put in your linker script. Instead, the loader decides what it will do with your binary, and you have to write a linker script that matches what the loader will do.
Post Reply