Skip to content

Commit 8334eba

Browse files
committed
arm: cortex_a_r linker: move data section between rodata and bss
By moving data section between rodata and bss, and disabling Kconfig LINKER_LAST_SECTION_ID by default if non-XIP (it is seems only needed for XIP), the size of zephyr.bin can be reduced significantly on non-XIP system. Signed-off-by: Dat Nguyen Duy <[email protected]>
1 parent d9eed16 commit 8334eba

File tree

1 file changed

+39
-40
lines changed
  • include/zephyr/arch/arm/cortex_a_r/scripts

1 file changed

+39
-40
lines changed

include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -282,34 +282,6 @@ SECTIONS
282282
_app_smem_rom_start = LOADADDR(_APP_SMEM_SECTION_NAME);
283283
#endif /* CONFIG_USERSPACE */
284284

285-
SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD), BSS_ALIGN)
286-
{
287-
/*
288-
* For performance, BSS section is assumed to be 4 byte aligned and
289-
* a multiple of 4 bytes
290-
*/
291-
. = ALIGN(4);
292-
__bss_start = .;
293-
__kernel_ram_start = .;
294-
295-
*(.bss)
296-
*(".bss.*")
297-
*(COMMON)
298-
*(".kernel_bss.*")
299-
300-
#ifdef CONFIG_CODE_DATA_RELOCATION
301-
#include <linker_sram_bss_relocate.ld>
302-
#endif
303-
304-
/*
305-
* As memory is cleared in words only, it is simpler to ensure the BSS
306-
* section ends on a 4 byte boundary. This wastes a maximum of 3 bytes.
307-
*/
308-
__bss_end = ALIGN(4);
309-
} GROUP_DATA_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)
310-
311-
#include <zephyr/linker/common-noinit.ld>
312-
313285
SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,)
314286
{
315287
__data_region_start = .;
@@ -345,12 +317,6 @@ SECTIONS
345317

346318
__data_region_end = .;
347319

348-
349-
/* Define linker symbols */
350-
351-
__kernel_ram_end = RAM_ADDR + RAM_SIZE;
352-
__kernel_ram_size = __kernel_ram_end - __kernel_ram_start;
353-
354320
#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_ocm), okay)
355321
GROUP_START(OCM)
356322

@@ -382,12 +348,6 @@ GROUP_END(OCM)
382348
*/
383349
#include <snippets-sections.ld>
384350

385-
#define LAST_RAM_ALIGN . = ALIGN(_region_min_align);
386-
387-
#include <zephyr/linker/ram-end.ld>
388-
389-
GROUP_END(RAMABLE_REGION)
390-
391351
#include <zephyr/linker/debug-sections.ld>
392352

393353
SECTION_PROLOGUE(.ARM.attributes, 0,)
@@ -413,4 +373,43 @@ GROUP_END(OCM)
413373
* calculate this value here. */
414374
_flash_used = LOADADDR(.last_section) + SIZEOF(.last_section) - __rom_region_start;
415375

376+
SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD), BSS_ALIGN)
377+
{
378+
/*
379+
* For performance, BSS section is assumed to be 4 byte aligned and
380+
* a multiple of 4 bytes
381+
*/
382+
. = ALIGN(4);
383+
__bss_start = .;
384+
__kernel_ram_start = .;
385+
386+
*(.bss)
387+
*(".bss.*")
388+
*(COMMON)
389+
*(".kernel_bss.*")
390+
391+
#ifdef CONFIG_CODE_DATA_RELOCATION
392+
#include <linker_sram_bss_relocate.ld>
393+
#endif
394+
395+
/*
396+
* As memory is cleared in words only, it is simpler to ensure the BSS
397+
* section ends on a 4 byte boundary. This wastes a maximum of 3 bytes.
398+
*/
399+
__bss_end = ALIGN(4);
400+
} GROUP_DATA_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)
401+
402+
#include <zephyr/linker/common-noinit.ld>
403+
404+
/* Define linker symbols */
405+
406+
__kernel_ram_end = RAM_ADDR + RAM_SIZE;
407+
__kernel_ram_size = __kernel_ram_end - __kernel_ram_start;
408+
409+
#define LAST_RAM_ALIGN . = ALIGN(_region_min_align);
410+
411+
#include <zephyr/linker/ram-end.ld>
412+
413+
GROUP_END(RAMABLE_REGION)
414+
416415
}

0 commit comments

Comments
 (0)