Skip to content

Commit 5fd1f5f

Browse files
committed
arm: linker.ld: move bss section to ram end
fix bss section be copy to binary. When compiling with non-xip. All sections will be placed in the ram. If NOBITS section isn't placed at the end of ram, objcopy will placed these section to binary file. The modify only for no-userspace. In userspace the section will be adjust, kobject_data size increase, the bss be shifted, the content of kobject_data will no mactch to kernel obj of bss. Signed-off-by: Frank Li <lgl88911@163.com>
1 parent c6fc36f commit 5fd1f5f

File tree

1 file changed

+49
-1
lines changed
  • include/arch/arm/aarch32/cortex_m/scripts

1 file changed

+49
-1
lines changed

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

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ SECTIONS
296296

297297
_app_smem_size = _app_smem_end - _app_smem_start;
298298
_app_smem_rom_start = LOADADDR(_APP_SMEM_SECTION_NAME);
299-
#endif /* CONFIG_USERSPACE */
300299

301300
SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD),)
302301
{
@@ -344,6 +343,8 @@ SECTIONS
344343

345344
} GROUP_LINK_IN(RAMABLE_REGION)
346345

346+
#endif /* CONFIG_USERSPACE */
347+
347348
SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,)
348349
{
349350
__data_ram_start = .;
@@ -381,6 +382,53 @@ SECTIONS
381382

382383
__data_ram_end = .;
383384

385+
#ifndef CONFIG_USERSPACE
386+
SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD),)
387+
{
388+
/*
389+
* For performance, BSS section is assumed to be 4 byte aligned and
390+
* a multiple of 4 bytes
391+
*/
392+
. = ALIGN(4);
393+
__bss_start = .;
394+
__kernel_ram_start = .;
395+
396+
*(.bss)
397+
*(".bss.*")
398+
*(COMMON)
399+
*(".kernel_bss.*")
400+
401+
#ifdef CONFIG_CODE_DATA_RELOCATION
402+
#include <linker_sram_bss_relocate.ld>
403+
#endif
404+
405+
/*
406+
* As memory is cleared in words only, it is simpler to ensure the BSS
407+
* section ends on a 4 byte boundary. This wastes a maximum of 3 bytes.
408+
*/
409+
__bss_end = ALIGN(4);
410+
} GROUP_DATA_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)
411+
412+
SECTION_PROLOGUE(_NOINIT_SECTION_NAME,(NOLOAD),)
413+
{
414+
/*
415+
* This section is used for non-initialized objects that
416+
* will not be cleared during the boot process.
417+
*/
418+
*(.noinit)
419+
*(".noinit.*")
420+
*(".kernel_noinit.*")
421+
422+
/* Located in generated directory. This file is populated by the
423+
* zephyr_linker_sources() Cmake function.
424+
*/
425+
#include <snippets-noinit.ld>
426+
#ifdef CONFIG_SOC_NOINIT_LD
427+
#include <soc-noinit.ld>
428+
#endif
429+
430+
} GROUP_LINK_IN(RAMABLE_REGION)
431+
#endif /* CONFIG_USERSPACE */
384432

385433
/* Define linker symbols */
386434

0 commit comments

Comments
 (0)