diff --git a/Kconfig.zephyr b/Kconfig.zephyr index 0e5c665b21d..89cdefdc87f 100644 --- a/Kconfig.zephyr +++ b/Kconfig.zephyr @@ -275,7 +275,7 @@ config LINKER_GENERIC_SECTIONS_PRESENT_AT_BOOT config LINKER_LAST_SECTION_ID bool "Last section identifier" - default y + default y if !ARM64 depends on ARM || ARM64 || RISCV help If enabled, the last section will contain an identifier. diff --git a/include/zephyr/arch/arm64/scripts/linker.ld b/include/zephyr/arch/arm64/scripts/linker.ld index a8fd0937b2e..d8d38df47e4 100644 --- a/include/zephyr/arch/arm64/scripts/linker.ld +++ b/include/zephyr/arch/arm64/scripts/linker.ld @@ -161,12 +161,10 @@ SECTIONS __exidx_end = .; } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) - __rodata_region_start = .; + MMU_ALIGN; + __rodata_region_start = .; #include -/* Located in generated directory. This file is populated by calling - * zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs. - */ #include #include @@ -184,9 +182,6 @@ SECTIONS *(.got) *(.got.plt) -/* Located in generated directory. This file is populated by the - * zephyr_linker_sources() Cmake function. - */ #include #include @@ -194,8 +189,8 @@ SECTIONS } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) #include - MMU_ALIGN; + MMU_ALIGN; __rodata_region_end = .; __rodata_region_size = __rodata_region_end - __rodata_region_start; __rom_region_end = .; @@ -214,19 +209,32 @@ SECTIONS GROUP_START(RAMABLE_REGION) +#ifdef CONFIG_XIP . = RAM_ADDR; - /* Align the start of image RAM with the - * minimum granularity required by MMU. - */ - . = ALIGN(_region_min_align); +#endif + MMU_ALIGN; _image_ram_start = .; #ifdef CONFIG_XIP z_mapped_start = .; #endif -/* Located in generated directory. This file is populated by the - * zephyr_linker_sources() Cmake function. - */ + __data_region_start = .; + + SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,) + { + MMU_ALIGN; + __data_start = .; + *(.data) + *(".data.*") + *(".kernel.*") + +#include + + __data_end = .; + } GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) + __data_size = __data_end - __data_start; + __data_load_start = LOADADDR(_DATA_SECTION_NAME); + #include #if defined(CONFIG_USERSPACE) @@ -249,6 +257,15 @@ SECTIONS _app_smem_rom_start = LOADADDR(_APP_SMEM_SECTION_NAME); #endif /* CONFIG_USERSPACE */ +#include +#include +#include + +#include + + __data_region_end = .; + __data_region_load_start = LOADADDR(_DATA_SECTION_NAME); + SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD), BSS_ALIGN) { . = ALIGN(8); @@ -265,48 +282,10 @@ SECTIONS #include - SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,) - { - __data_region_start = .; - __data_start = .; - *(.data) - *(".data.*") - *(".kernel.*") - -/* Located in generated directory. This file is populated by the - * zephyr_linker_sources() Cmake function. - */ -#include - - __data_end = .; - - } GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) - __data_size = __data_end - __data_start; - __data_load_start = LOADADDR(_DATA_SECTION_NAME); - - __data_region_load_start = LOADADDR(_DATA_SECTION_NAME); - -#include -#include -#include - -/* Located in generated directory. This file is populated by the - * zephyr_linker_sources() Cmake function. - */ -#include - - __data_region_end = .; - - /* Define linker symbols */ - __kernel_ram_end = RAM_ADDR + RAM_SIZE; __kernel_ram_size = __kernel_ram_end - __kernel_ram_start; - -/* Located in generated directory. This file is populated by the - * zephyr_linker_sources() Cmake function. - */ #include #define LAST_RAM_ALIGN MMU_ALIGN;