S32K144: ld file, user-defined section caused bin file size larger

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

S32K144: ld file, user-defined section caused bin file size larger

Jump to solution
1,616 Views
dsfire
Contributor III

Hi, all,

I add a new section 'nvram_section' which data validity was checked by userself below .bss section.

when I defined a variable such as < __attribute__((section(".nvram"))) char test >, the target bin file size is larger than < char test > defined.
The increased part size is about 40kB and was filled with zero, but both of hex file size is almost equal.

1. what the root cause of this phenomenon
2. how to add a user-defined section for data validity checked by userself rather than variable filled with specific value like in .data section or variable filled with zero in .bss section.
/* Uninitialized data section. */
.bss :
{
/* This is used by the startup in order to initialize the .bss section. */
. = ALIGN(4);
__BSS_START = .;
__bss_start__ = .;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
__bss_end__ = .;
__BSS_END = .;
} > m_data_2

/* data checked by user. */
.nvram_section :
{
. = ALIGN(4);
__NVRAM_START = .;
__start__ = .;
*(.nvram)
. = ALIGN(4);
__nvram_end__ = .;
__NVRAM_END = .;
} > m_data_2
.heap :
{
. = ALIGN(8);
__end__ = .;
PROVIDE(end = .);
PROVIDE(_end = .);
PROVIDE(__end = .);
__HeapBase = .;
. += HEAP_SIZE;
__HeapLimit = .;
__heap_limit = .;
} > m_data_2

Regards,

Liu

Labels (1)
0 Kudos
1 Solution
1,269 Views
dsfire
Contributor III

Hello Martin,

Thanks for your reply.

Currently, i add a (NOLOAD) flag in nvram_section like below.

It seems to work well.

Is correct for this modification?

/* data checked by user. */
.nvram_section (NOLOAD):
{
. = ALIGN(4);
__NVRAM_START = .;
__start__ = .;
*(.nvram)
. = ALIGN(4);
__nvram_end__ = .;
__NVRAM_END = .;
} > m_data_2

Regards,

Liu

View solution in original post

0 Kudos
4 Replies
1,269 Views
martin_kovar
NXP Employee
NXP Employee

Hello Liu,

The phenomenon you describe is typical behavior of bin file, which fills your section by zeros. Because you have defined active section in your linker file, this must be filled by some values in bin file.

If you would like to avoid this phenomenon, use srecord instead of bin file. If you use srecord instead of bin, you will see only 4 bytes plus size, because use one char variable which is one byte, but aligned to 4 bytes.

Regards,
Martin

0 Kudos
1,270 Views
dsfire
Contributor III

Hello Martin,

Thanks for your reply.

Currently, i add a (NOLOAD) flag in nvram_section like below.

It seems to work well.

Is correct for this modification?

/* data checked by user. */
.nvram_section (NOLOAD):
{
. = ALIGN(4);
__NVRAM_START = .;
__start__ = .;
*(.nvram)
. = ALIGN(4);
__nvram_end__ = .;
__NVRAM_END = .;
} > m_data_2

Regards,

Liu

0 Kudos
1,269 Views
martin_kovar
NXP Employee
NXP Employee

Hello Liu,

yes, using NOLOAD is also correct. Thank you for good point.

Regards,

Martin

0 Kudos
1,269 Views
dsfire
Contributor III

Hello Martin,

Thanks for your information.

Regards,

Liu

0 Kudos