Skip to content

Commit f9d69fc

Browse files
gramsay0kartben
authored andcommitted
arch: arm: cortex_m: Consolidate bss/noinit sections for kernel/user mode
Userspace originally required bss to precede kobject_data, as kobject_data size was not known until the final linking stage (#21747). #33687 reserved space for kobject_data, allowing bss to now be after kobject_data. Placing bss/noinit at the end of the linker script reduces the size of a "zephyr.bin" file, as the NOLOAD sections can be excluded. It also keeps the code common between kernel/user mode Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
1 parent d9aab69 commit f9d69fc

File tree

1 file changed

+2
-48
lines changed
  • include/zephyr/arch/arm/cortex_m/scripts

1 file changed

+2
-48
lines changed

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

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -277,35 +277,6 @@ SECTIONS
277277

278278
_app_smem_size = _app_smem_end - _app_smem_start;
279279
_app_smem_rom_start = LOADADDR(_APP_SMEM_SECTION_NAME);
280-
281-
SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD),)
282-
{
283-
/*
284-
* For performance, BSS section is assumed to be 4 byte aligned and
285-
* a multiple of 4 bytes
286-
*/
287-
. = ALIGN(4);
288-
__bss_start = .;
289-
__kernel_ram_start = .;
290-
291-
*(.bss)
292-
*(".bss.*")
293-
*(COMMON)
294-
*(".kernel_bss.*")
295-
296-
#ifdef CONFIG_CODE_DATA_RELOCATION
297-
#include <linker_sram_bss_relocate.ld>
298-
#endif
299-
300-
/*
301-
* As memory is cleared in words only, it is simpler to ensure the BSS
302-
* section ends on a 4 byte boundary. This wastes a maximum of 3 bytes.
303-
*/
304-
__bss_end = ALIGN(4);
305-
} GROUP_DATA_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)
306-
307-
#include <zephyr/linker/common-noinit.ld>
308-
309280
#endif /* CONFIG_USERSPACE */
310281

311282
GROUP_START(DATA_REGION)
@@ -449,8 +420,7 @@ SECTION_PROLOGUE(.last_section,,)
449420
* calculate this value here. */
450421
_flash_used = LOADADDR(.last_section) + SIZEOF(.last_section) - __rom_region_start;
451422

452-
#ifndef CONFIG_USERSPACE
453-
SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD),)
423+
SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD),)
454424
{
455425
/*
456426
* For performance, BSS section is assumed to be 4 byte aligned and
@@ -476,23 +446,7 @@ _flash_used = LOADADDR(.last_section) + SIZEOF(.last_section) - __rom_region_sta
476446
__bss_end = ALIGN(4);
477447
} GROUP_DATA_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)
478448

479-
SECTION_PROLOGUE(_NOINIT_SECTION_NAME,(NOLOAD),)
480-
{
481-
/*
482-
* This section is used for non-initialized objects that
483-
* will not be cleared during the boot process.
484-
*/
485-
*(.noinit)
486-
*(".noinit.*")
487-
*(".kernel_noinit.*")
488-
489-
/* Located in generated directory. This file is populated by the
490-
* zephyr_linker_sources() Cmake function.
491-
*/
492-
#include <snippets-noinit.ld>
493-
494-
} GROUP_NOLOAD_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)
495-
#endif /* CONFIG_USERSPACE */
449+
#include <zephyr/linker/common-noinit.ld>
496450

497451
/* Define linker symbols */
498452

0 commit comments

Comments
 (0)