Incorrect map file generation

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Incorrect map file generation

Jump to solution
985 Views
darq
Contributor III

Hello,

I'm using S32 Design Studio Version: 2.1 Build id: 190624. I am trying to use some symbols defined in linker file but i get incorrect results. The is a stack section define as follows:

.stack (NOLOAD) : ALIGN(0x1000)
{
__HEAP = . ;
PROVIDE (_end = . );
PROVIDE (end = . );
. += __HEAP_SIZE ;
__HEAP_END = . ;
TEST = (SRAM_BASE_ADDR + SRAM_SIZE + 1 - __STACK_SIZE);
TEST_1 = __HEAP_END;
TEST_2 = TEST - TEST_1;
TEST_3 = 1 + 3;
TEST_4 = TEST_3 - 1;
_stack_end = . ;
. += __STACK_SIZE ;
_stack_addr = . ;
__SP_INIT = . ;
. += 4;
} > m_data

 

After build the TEST_X values generated are incorrect:

.stack 0x40050000 0x3004 load address 0xa004c000
0x40050000 __HEAP = .
[!provide] PROVIDE (_end, .)
0x40050000 PROVIDE (end, .)
0x40051000 . = (. + __HEAP_SIZE)
*fill* 0x40050000 0x1000
0x40051000 __HEAP_END = .
0x4005e000 TEST = (((SRAM_BASE_ADDR + SRAM_SIZE) + 0x1) - __STACK_SIZE)
0x40051000 TEST_1 = __HEAP_END
0x4005d000 TEST_2 = (TEST - TEST_1)
0x00000004 TEST_3 = 0x4
0x40050003 TEST_4 = (TEST_3 - 0x1)
0x40051000 _stack_end = .
0x40053000 . = (. + __STACK_SIZE)
*fill* 0x40051000 0x2000
0x40053000 _stack_addr = .
0x40053000 __SP_INIT = .

For TEST_2 and TEST_4 the upper two bytes for some reason have value 0x4005. Can someone explain why is is generated like this? Sorry if i made some stupid mistake, i don't usually work with linker files.

Best regards

 

0 Kudos
1 Solution
962 Views
stanish
NXP Employee
NXP Employee

Hi Darq,

It seems there is a confusion between absolute and relative symbols.

Symbols within section definition are relative by default.

I'd suggest you to define the "constant" symbols as absolute e.g.

TEST = ABSOLUTE(SRAM_BASE_ADDR + SRAM_SIZE + 1 - __STACK_SIZE);
TEST_1 = ABSOLUTE(__HEAP_END);
TEST_2 = TEST - TEST_1;
TEST_3 = ABSOLUTE (1 + 3);

TEST_4 = TEST_3 - 1;

for more information please check this link:

https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_chapter/ld_3.html#SEC13

Hope it helps.

Stan

View solution in original post

0 Kudos
1 Reply
963 Views
stanish
NXP Employee
NXP Employee

Hi Darq,

It seems there is a confusion between absolute and relative symbols.

Symbols within section definition are relative by default.

I'd suggest you to define the "constant" symbols as absolute e.g.

TEST = ABSOLUTE(SRAM_BASE_ADDR + SRAM_SIZE + 1 - __STACK_SIZE);
TEST_1 = ABSOLUTE(__HEAP_END);
TEST_2 = TEST - TEST_1;
TEST_3 = ABSOLUTE (1 + 3);

TEST_4 = TEST_3 - 1;

for more information please check this link:

https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_chapter/ld_3.html#SEC13

Hope it helps.

Stan

0 Kudos