Skip to content

Commit eb7ac1c

Browse files
Dat-NguyenDuykartben
authored andcommitted
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. As a result, moving __kernel_ram_start to another place to ensure it still include bss + data as before. Signed-off-by: Dat Nguyen Duy <[email protected]>
1 parent 3a07c25 commit eb7ac1c

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
@@ -285,36 +285,9 @@ SECTIONS
285285
_app_smem_rom_start = LOADADDR(_APP_SMEM_SECTION_NAME);
286286
#endif /* CONFIG_USERSPACE */
287287

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

349322
__data_region_end = .;
350323

351-
352-
/* Define linker symbols */
353-
354-
__kernel_ram_end = RAM_ADDR + RAM_SIZE;
355-
__kernel_ram_size = __kernel_ram_end - __kernel_ram_start;
356-
357324
#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_ocm), okay)
358325
GROUP_START(OCM)
359326

@@ -385,12 +352,6 @@ GROUP_END(OCM)
385352
*/
386353
#include <snippets-sections.ld>
387354

388-
#define LAST_RAM_ALIGN . = ALIGN(_region_min_align);
389-
390-
#include <zephyr/linker/ram-end.ld>
391-
392-
GROUP_END(RAMABLE_REGION)
393-
394355
#include <zephyr/linker/debug-sections.ld>
395356

396357
SECTION_PROLOGUE(.ARM.attributes, 0,)
@@ -416,4 +377,42 @@ GROUP_END(OCM)
416377
* calculate this value here. */
417378
_flash_used = LOADADDR(.last_section) + SIZEOF(.last_section) - __rom_region_start;
418379

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

0 commit comments

Comments
 (0)