0
votes

Iam writing a GNU linker script file and need a nudge in the right direction for the following problem.

The device for which the linker script is being created has flash for hosting text and rodata. It has also SRAM for hosting Data and BSS.

I have created variants of linker script which has: - CODE and RODATA loaded into flash while DATA and BSS are in SRAM - CODE, RODATA, DATA and BSS in SRAM

These work fine.

I must now create a variant of the linker script which has a majority of TEXT in flash. But certain routines with names ending with a well known suffix are to be loaded into SRAM.

For example, I would like Func1IRAMCode() and Func2__IRAMCode() to be loaded into SRAM section while every other function that does not have a IRAMCode suffix must be loaded into flash.

For portability reasons, I wont attach attribute(section) to these SRAM functions.

Here is where am stumbling. The text section has the following rule:

.text :
{
*(.text .text.* .gnu.linkonce.t.*);
} > FLASH

.Misc :
{
* (.text.*IRAMCode);
} > SRAM

.data and .bss sections are defined seperately.

Problem is that *IRAMCode() are getting assigned flash addresses.

What is the syntax to exclude *IRAMCode from text section?

How have you solved this problem in your projects?

1
I worked around this by linking the TEXT section of all object files with desired IRAM* code into SRAM instead of selectively linking the routines. Not a scalable workaround..Raj

1 Answers

0
votes

A way to do this, is to put your functions in another section (for example .sram.text ), to do this, use the section attribute of gcc for each specific function ( ex : __attribute__ (( section ".sram.text")) .

Thus, it will be very easy to wildcard the desired section to the SRAM.