Managed linker scripts are great on one side: the simplify the otherwise complex GNU linker script handling. On the other side it requires knowledge how to tweak them in case ‘non-standard’ behavior is needed.
I described the context in Putting Code of Files into Special Section with the GNU Linker.
This is very useful for example putting code or data into specific memory areas, for example if using position independent code or in the context of libraries and bootloaders.
The question is: how to do this with a managed linker script as in the NXP MCUXpresso IDE?
First, we need a memory section which we can use. I’m using here the NXP LPC55S16 which has one text/FLASH region, so I used the ‘Split’ button to have another section:
The next thing is that I have to specify which code I want to place into this section. There is an ‘extra linker script input section’ I can use:
- Input section description: The text used in the linker script. I can use wildcards (*) and specify the file name(s). After the file name I can specify the section names with wildcards too.
- Region: The region name I have defined
- Section Type: The linker script will be split into different areas like .text or .data. Specify for which section kind it shall be used.
What it does is creating an extra placement in the linker script file like this one:
With this, check the placement in the linker *.map file:
The image below shows the full flow:
With this, I can place code (or data) into specific sections using managed linker scripts.
Happy placing 🙂