Linker script
Linker script
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

- Posts: 6245
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Linker script
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.
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.