Dynamic Memory Usage using Linker Script Programming

Hi, I got some special tricks for the Linker Scripts for a non-contiguous memory map in which i can distribute code or data among more than one memory area.

MEMORY { PR_MEM1: origin = 0a000h, length = 0500h; PR_MEM2: origin = 0d000h, length = 0300h; }

SECTIONS { .text_1: { test1.obj(.text), test2.obj(.text), test3.obj(.text) }

PR_MEM1

.text_2: { test4.obj(.text), test5.obj(.text) } > PR_MEM2 }

Another trick of splitting the output sections among multiple memory areas to automatically achieve an efficient allocation of the output section among several memory areas as below :

SECTIONS { .text: { *(.text) } >> PR_MEM1 | PR_MEM2 }

But, i have many other queries. Consider the below scenario. Application 'A' gets loaded first and starts running. After application 'A' starts to run, Application 'B' gets loaded and starts running.

Consider that application 'A' has for following memory map Data_Mem -> 0x20001000 to 0x20006000 (Though so much is allocated, this application 'A' actually uses only upto 0x20002000 in runtime - This info, i collected from MAP file) ( Has the bss,stack,bss,data,idata )

Application 'B' has the following memory map. Data_Mem -> 0x20001000 to 0x20006000 (This uses only upto 0x20004000 in runtime).( Has the bss,stack,bss,data,idata )

Though both application A and Application B point to same memory area w.r.t Data_Mem, from the above it is clear that there is some memory area unused by application A that can be used by application B. How to tell the Application B to take the unused memory space of the Application A. ?

Is there any feature for doing that in Linker Scripts ? If we allocate certain regions via Linker Scripts, is it not possible to allocate some part of that region to other module ?

I thought 'Load' and 'Run' feature can be used. But, i find that they both allocate separate memory blocks and so result in wastage of usable area.

In short, How to do Dynamic Memory Usage using Linker Script Programming ?

Thx in advans, Karthik Balaguru

Reply to
karthikbg
Loading thread data ...

PR_MEM1 .text_2: { test4.obj(.text), test5.obj(.text) } > PR_MEM2

Hi,

I do not find any option in Linker Script for passing values from another file to Linker Script. Is it there ? ( Did i miss it :( ?? ) I think, i will write my own Perl Script for extracting the used memory info from MAP file to find the remaining unused space and write that unused space at the corresponding location in the Linker Command File. But, if there is an option available with the Linker Command File programming for information exchange with MAP file, it would be really nice. Is it there ?

Below is the scenario : I need to tell application 'A' to use the unused space of application 'B' .

, but this info has to be told to application 'A'. How to tell my Linker Command FIle (Linker Scripts) of application 'A' that the application 'B' has some amount of Unused memory in a certain region and so the application 'A' can use that memory ? That is , how to do information exchange between MAP file and Linker Script using Linker Script programming techniques ?

Thx in advans, Karthik Balaguru

Reply to
karthikbg

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.