linker feature to dynamically allocate objects to multiple segments

Asked by Henry Cheang

Hello,

I'm working with Freescale M0, M4 parts. One hardware restriction is that there can be no burst memory access across the two SRAM array boundary (usually 0x20000000). Currently the work-around is to modify the linker script to define two separate memory segments so that linker would not allocate objects across the boundary however user would have to manually place objects to separate sections thru __attribute__(section).

Are you aware of other cortex-M parts that has this restriction? Is there any plan to support a feature where the linker could dynamically allocation objects to multiple segments thru special linker script syntax? e.g.:

sram_l (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x00010000
sram_u (RW) : ORIGIN = 0x20000000, LENGTH = 0x00010000

.data :
{

} > sram_l, sram_u

when sram_l is full, linker would start allocating objects to sram_u. Thus there would be no chance for objects to cross the segment boundary.

Thanks!
Henry

Question information

Language:
English Edit question
Status:
Answered
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
chengbin (can-finner) said :
#1

Hi Henry Cheang,
How about following method:

STEP1, Define two memory segments as you mentioned;

STEP2, Split data section into .data1/.data2 sections too;

STEP3, Writing .data1/.data2 input section descriptions like following:

.data1 :
{
  ...
  *(EXCLUDE_FILE(data.o) .data*)
  ...
} > RAM1
.data2 :
{
  ...
  data.o(.data*)
  ...
} > RAM2

In this way, you don't need to specify section attribute for each single variable
and linker puts data from data.o into RAM2, while others into RAM1.

Unfortunately, there is a problem with this method: you probably have to use
ld in command line directly, rather than using gcc as a linker front end.

This is because gcc uses temporary names for object files, which are unknown
in linker script.

Hoping this help for the moment.

Revision history for this message
Joey Ye (jinyun-ye) said :
#2

Henry,

I'm afraid linker script is one area not in our plan now, but it is
welcomed for anyone to post a solution and patch. Bin's proposal can help
in some circumstance, though not fully solve the problem.

Thanks - Joey

On Fri, Jun 29, 2012 at 11:25 AM, chengbin <
<email address hidden>> wrote:

> Question #201738 on GCC ARM Embedded changed:
> https://answers.launchpad.net/gcc-arm-embedded/+question/201738
>
> Status: Open => Answered
>
> chengbin proposed the following answer:
> Hi Henry Cheang,
> How about following method:
>
> STEP1, Define two memory segments as you mentioned;
>
> STEP2, Split data section into .data1/.data2 sections too;
>
> STEP3, Writing .data1/.data2 input section descriptions like following:
>
> .data1 :
> {
> ...
> *(EXCLUDE_FILE(data.o) .data*)
> ...
> } > RAM1
> .data2 :
> {
> ...
> data.o(.data*)
> ...
> } > RAM2
>
> In this way, you don't need to specify section attribute for each single
> variable
> and linker puts data from data.o into RAM2, while others into RAM1.
>
> Unfortunately, there is a problem with this method: you probably have to
> use
> ld in command line directly, rather than using gcc as a linker front end.
>
> This is because gcc uses temporary names for object files, which are
> unknown
> in linker script.
>
> Hoping this help for the moment.
>
> --
> You received this question notification because you are an answer
> contact for GCC ARM Embedded.
>

Can you help with this problem?

Provide an answer of your own, or ask Henry Cheang for more information if necessary.

To post a message you must log in.