cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
2,399 Views
Registered: ‎04-23-2018

how to use user defined sections from linker script in application code

Jump to solution

hi,

I generated a memory segment 'data_ddr0' using add memory option in linker script. I created  a section inside that as below

 

.lrr_data : {
. = ALIGN(64);
__lrr_data_start = .;


__lrr_data_end = .;
} > data_ddr0

 

 

i want to know how to create a section inside this so that i can use that section inside application code.

 

i want to define an array inside the section what we create as above ? what is syntax for using this section in c code?

 

Regards,

sarath

0 Kudos
1 Solution

Accepted Solutions
smcnutt
Contributor
Contributor
2,719 Views
Registered: ‎04-04-2018

> i want to define an array inside the section

 

E.g. - Put an array of char in your .llr_data section:

 

#define BUFSZ   0x1000 /* For example */

char __attribute__((__section__(".lrr_data"))) buf[BUFSZ];

 

The use 'buf' as you always would.

 

View solution in original post

5 Replies
smcnutt
Contributor
Contributor
2,720 Views
Registered: ‎04-04-2018

> i want to define an array inside the section

 

E.g. - Put an array of char in your .llr_data section:

 

#define BUFSZ   0x1000 /* For example */

char __attribute__((__section__(".lrr_data"))) buf[BUFSZ];

 

The use 'buf' as you always would.

 

View solution in original post

2,354 Views
Registered: ‎04-23-2018

thank you thanks a lot.

 

can you kindly tell me do i need to add anything inside below code, which i wrote inside linker file (.ld)?

 

.lrr_data : {
. = ALIGN(64);
__lrr_data_start = .;


__lrr_data_end = .;
} > LRR_data_ddr0

 

Regards,

sarath

 

 

0 Kudos
smcnutt
Contributor
Contributor
2,341 Views
Registered: ‎04-04-2018

 

> can you kindly tell me do i need to add anything

> inside below code, which i wrote inside linker file (.ld)?

 

Normally, yes. In your case you'll want to specify the input sections.

 

.lrr_data : {
    . = ALIGN(64);
    __lrr_data_start = .;
    *(.lrr_data)
    __lrr_data_end = .;
} > LRR_data_ddr0

All of the details can be found in the gnu ld docs.

 

 

2,318 Views
Registered: ‎04-23-2018

Thank you.

 

i had another issue now. Basically i am trying to put my buffers in different sections . i am getting some error like this .can you help me to resolve this? Error statement i am mentioning down.

 

Description Resource Path Location Type
relocation truncated to fit: R_AARCH64_ADR_PREL_PG_HI21 against symbol `peak' defined in .lrr_data section in ./src/src/main.o LRR_StandAloneCore3 line 0, external location: D:\NIDEC_LRR_2018\Working_Directory\vivado\LRR_StandAlone\sdkCore3\src\main.c:44 C/C++ Problem

 

 

Regards,

Sarath

0 Kudos
smcnutt
Contributor
Contributor
2,266 Views
Registered: ‎04-04-2018

I know the error/warning messages can be overly cryptic. And sometimes they appear almost completely useless to the rank and file, but you have to read them carefully & do your best to figure out what they are trying to tell you:

 

relocation truncated to fit: R_AARCH64_ADR_PREL_PG_HI21 against symbol `peak' defined in .lrr_data section in ./src/src/main.o LRR_StandAloneCore3 line 0, external location: D:\NIDEC_LRR_2018\Working_Directory\vivado\LRR_StandAlone\sdkCore3\src\main.c:44 C/C++

 

I would guess you have a symbol (table, array, etc.)  'peak' that is too big to fit into the .lrr_data section, so it was truncated.

 

It's probably time for you to dig into the ld manual -- there's a lot of really interesting and useful stuff in there.