@ -1,14 +1,38 @@
set ( COMMON_ZEPHYR_LINKER_DIR ${ ZEPHYR_BASE } /cmake/linker_script/common )
set ( COMMON_ZEPHYR_LINKER_DIR ${ ZEPHYR_BASE } /cmake/linker_script/common )
set_ifndef ( region_min_align CONFIG_CUSTOM_SECTION_MIN_ALIGN_SIZE )
# T h i s s h o u l d b e d i f f e r e n t f o r c o r t e x _ r o r c o r t e x _ a . . . .
# c u t f r o m z e p h y r / i n c l u d e / z e p h y r / a r c h / a r m / c o r t e x _ m / s c r i p t s / l i n k e r . l d
if ( DEFINED CONFIG_CUSTOM_SECTION_MIN_ALIGN_SIZE )
set_ifndef ( region_min_align ${ CONFIG_CUSTOM_SECTION_MIN_ALIGN_SIZE } )
endif ( )
# S e t a l i g n m e n t t o C O N F I G _ A R M _ M P U _ R E G I O N _ M I N _ A L I G N _ A N D _ S I Z E i f n o t s e t a b o v e
# S e t a l i g n m e n t t o C O N F I G _ A R M _ M P U _ R E G I O N _ M I N _ A L I G N _ A N D _ S I Z E i f n o t s e t a b o v e
# t o m a k e l i n k e r s e c t i o n a l i g n m e n t c o m p l y w i t h M P U g r a n u l a r i t y .
# t o m a k e l i n k e r s e c t i o n a l i g n m e n t c o m p l y w i t h M P U g r a n u l a r i t y .
set_ifndef ( region_min_align CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE )
if ( DEFINED CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE )
set_ifndef ( region_min_align ${ CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE } )
endif ( )
# I f b u i l d i n g w i t h o u t M P U s u p p o r t , u s e d e f a u l t 4 - b y t e a l i g n m e n t . . i f n o t s e t a b o v e .
# I f b u i l d i n g w i t h o u t M P U s u p p o r t , u s e d e f a u l t 4 - b y t e a l i g n m e n t . . i f n o t s e t a b o v e .
set_ifndef ( region_min_align 4 )
set_ifndef ( region_min_align 4 )
zephyr_linker_include_var ( VAR region_min_align )
if ( ( NOT DEFINED CONFIG_CUSTOM_SECTION_ALIGN ) AND DEFINED CONFIG_MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT )
# d e f i n e MPU_ALIGN ( region_size ) \
# . = ALIGN ( _region_min_align ) ; \
# . = ALIGN ( 1 << LOG2CEIL(region_size ) )
# H a n d l i n g t h i s r e q u i r e s u s t o h a n d l e log2ceil ( ) i n i a r l i n k e r s i n c e t h e s i z e
# i s n ' t k n o w n u n t i l t h e n .
set ( MPU_ALIGN_BYTES ${ region_min_align } )
# message ( WARNING "We can not handle . = ALIGN( 1 << LOG2CEIL(region_size)) " )
else ( )
set ( MPU_ALIGN_BYTES ${ region_min_align } )
endif ( )
# T h e A P P _ S H A R E D _ A L I G N a n d S M E M _ P A R T I T I O N _ A L I G N m a c r o s a r e d e f i n e d a s
# " . = ALIGN ( ... ) " t h i n g s .
# t h e c m a k e g e n e r a t o r s t u f f n e e d s a n a l i g n - s i z e i n b y t e s s o :
zephyr_linker_include_var ( VAR APP_SHARED_ALIGN_BYTES VALUE ${ region_min_align } )
zephyr_linker_include_var ( VAR SMEM_PARTITION_ALIGN_BYTES VALUE ${ MPU_ALIGN_BYTES } )
# N o t e , t h e ` + 0 ` i n f o r m u l a s b e l o w a v o i d s e r r o r s i n c a s e s w h e r e a K c o n f i g
# N o t e , t h e ` + 0 ` i n f o r m u l a s b e l o w a v o i d s e r r o r s i n c a s e s w h e r e a K c o n f i g
# v a r i a b l e i s u n d e f i n e d a n d t h u s e x p a n d s t o n o t h i n g .
# v a r i a b l e i s u n d e f i n e d a n d t h u s e x p a n d s t o n o t h i n g .
math ( EXPR FLASH_ADDR
math ( EXPR FLASH_ADDR
@ -59,6 +83,7 @@ zephyr_linker_group(NAME RAM_REGION VMA RAM LMA ROM_REGION)
zephyr_linker_group ( NAME TEXT_REGION GROUP ROM_REGION SYMBOL SECTION )
zephyr_linker_group ( NAME TEXT_REGION GROUP ROM_REGION SYMBOL SECTION )
zephyr_linker_group ( NAME RODATA_REGION GROUP ROM_REGION )
zephyr_linker_group ( NAME RODATA_REGION GROUP ROM_REGION )
zephyr_linker_group ( NAME DATA_REGION GROUP RAM_REGION SYMBOL SECTION )
zephyr_linker_group ( NAME DATA_REGION GROUP RAM_REGION SYMBOL SECTION )
zephyr_linker_group ( NAME NOINIT_REGION GROUP RAM_REGION SYMBOL SECTION )
# s h o u l d g o t o a r e l o c a t i o n . c m a k e - f r o m i n c l u d e / l i n k e r / r e l - s e c t i o n s . l d - s t a r t
# s h o u l d g o t o a r e l o c a t i o n . c m a k e - f r o m i n c l u d e / l i n k e r / r e l - s e c t i o n s . l d - s t a r t
zephyr_linker_section ( NAME .rel.plt HIDDEN )
zephyr_linker_section ( NAME .rel.plt HIDDEN )
@ -82,6 +107,8 @@ zephyr_linker_section(NAME .text GROUP TEXT_REGION)
zephyr_linker_section_configure ( SECTION .rel.plt INPUT ".rel.iplt" )
zephyr_linker_section_configure ( SECTION .rel.plt INPUT ".rel.iplt" )
zephyr_linker_section_configure ( SECTION .rela.plt INPUT ".rela.iplt" )
zephyr_linker_section_configure ( SECTION .rela.plt INPUT ".rela.iplt" )
include ( ${ COMMON_ZEPHYR_LINKER_DIR } /kobject-text.cmake )
zephyr_linker_section_configure ( SECTION .text INPUT ".TEXT.*" )
zephyr_linker_section_configure ( SECTION .text INPUT ".TEXT.*" )
zephyr_linker_section_configure ( SECTION .text INPUT ".gnu.linkonce.t.*" )
zephyr_linker_section_configure ( SECTION .text INPUT ".gnu.linkonce.t.*" )
@ -107,9 +134,9 @@ include(${COMMON_ZEPHYR_LINKER_DIR}/thread-local-storage.cmake)
zephyr_linker_section ( NAME .rodata GROUP RODATA_REGION )
zephyr_linker_section ( NAME .rodata GROUP RODATA_REGION )
zephyr_linker_section_configure ( SECTION .rodata INPUT ".gnu.linkonce.r.*" )
zephyr_linker_section_configure ( SECTION .rodata INPUT ".gnu.linkonce.r.*" )
if ( CONFIG_USERSPACE AND CONFIG_XIP )
zephyr_linker_section_configure ( SECTION .rodata INPUT ".kobject_data.rodata*" )
include ( ${ COMMON_ZEPHYR_LINKER_DIR } /kobject-rom.cmake )
endif ( )
zephyr_linker_section_configure ( SECTION .rodata ALIGN 4 )
zephyr_linker_section_configure ( SECTION .rodata ALIGN 4 )
# T o D o - . = ALIGN ( _region_min_align ) ;
# T o D o - . = ALIGN ( _region_min_align ) ;
@ -119,13 +146,33 @@ zephyr_linker_section_configure(SECTION .rodata ALIGN 4)
zephyr_linker_section ( NAME .ramfunc GROUP RAM_REGION SUBALIGN 8 )
zephyr_linker_section ( NAME .ramfunc GROUP RAM_REGION SUBALIGN 8 )
# T o d o : h a n d l e MPU_ALIGN ( _ramfunc_size ) ;
# T o d o : h a n d l e MPU_ALIGN ( _ramfunc_size ) ;
# T o D o - h a n d l e if ( CONFIG_USERSPACE )
if ( CONFIG_USERSPACE )
# T h i s i s w h e r e t h e a p p _ m e m _ p a r t i t i o n s t u f f i s g o i n g t o b e p l a c e d , o n c e i t
# i s g e n e r a t e d b y g e n _ a p p _ p a r t i t i o n s . p y . _ a p p _ s m e m h a s i t s o w n i n i t - c o p y
# h a n d l i n g i n z _ d a t a _ c o p y , s o p u t i t i n R A M _ R E G I O M r a t h e r t h a n D A T A _ R E G I O N
zephyr_linker_group ( NAME APP_SMEM_GROUP GROUP RAM_REGION SYMBOL SECTION )
zephyr_linker_symbol ( SYMBOL "_app_smem_size" EXPR "@__app_smem_group_size@" )
zephyr_linker_symbol ( SYMBOL "_app_smem_rom_start" EXPR "@__app_smem_group_load_start@" )
zephyr_linker_section ( NAME .bss VMA RAM LMA FLASH TYPE BSS )
zephyr_linker_section_configure ( SECTION .bss INPUT COMMON )
zephyr_linker_section_configure ( SECTION .bss INPUT ".kernel_bss.*" )
# T O D O : t h e s k e l e t o n s i n c l u d e s < l i n k e r _ s r a m _ b s s _ r e l o c a t e . l d > h e r e
# A s m e m o r y i s c l e a r e d i n w o r d s o n l y , i t i s s i m p l e r t o e n s u r e t h e B S S
# s e c t i o n e n d s o n a 4 b y t e b o u n d a r y . T h i s w a s t e s a m a x i m u m o f 3 b y t e s .
zephyr_linker_section_configure ( SECTION .bss ALIGN 4 )
include ( ${ COMMON_ZEPHYR_LINKER_DIR } /common-noinit.cmake )
endif ( )
zephyr_linker_section ( NAME .data GROUP DATA_REGION )
zephyr_linker_section ( NAME .data GROUP DATA_REGION ALIGN_WITH_INPUT )
zephyr_linker_section_configure ( SECTION .data INPUT ".kernel.*" )
zephyr_linker_section_configure ( SECTION .data INPUT ".kernel.*" )
include ( ${ COMMON_ZEPHYR_LINKER_DIR } /common-ram.cmake )
include ( ${ COMMON_ZEPHYR_LINKER_DIR } /common-ram.cmake )
# include ( kobject.ld )
include ( ${ COMMON_ZEPHYR_LINKER_DIR } /kobject-data.cmake )
if ( NOT CONFIG_USERSPACE )
if ( NOT CONFIG_USERSPACE )
zephyr_linker_section ( NAME .bss VMA RAM LMA FLASH TYPE BSS )
zephyr_linker_section ( NAME .bss VMA RAM LMA FLASH TYPE BSS )
@ -135,7 +182,7 @@ if(NOT CONFIG_USERSPACE)
# s e c t i o n e n d s o n a 4 b y t e b o u n d a r y . T h i s w a s t e s a m a x i m u m o f 3 b y t e s .
# s e c t i o n e n d s o n a 4 b y t e b o u n d a r y . T h i s w a s t e s a m a x i m u m o f 3 b y t e s .
zephyr_linker_section_configure ( SECTION .bss ALIGN 4 )
zephyr_linker_section_configure ( SECTION .bss ALIGN 4 )
zephyr_linker_section ( NAME .noinit GROUP RAM _REGION TYPE NOLOAD NOINIT )
zephyr_linker_section ( NAME .noinit GROUP NOINIT _REGION TYPE NOLOAD NOINIT )
# T h i s s e c t i o n i s u s e d f o r n o n - i n i t i a l i z e d o b j e c t s t h a t
# T h i s s e c t i o n i s u s e d f o r n o n - i n i t i a l i z e d o b j e c t s t h a t
# w i l l n o t b e c l e a r e d d u r i n g t h e b o o t p r o c e s s .
# w i l l n o t b e c l e a r e d d u r i n g t h e b o o t p r o c e s s .
zephyr_linker_section_configure ( SECTION .noinit INPUT ".kernel_noinit.*" )
zephyr_linker_section_configure ( SECTION .noinit INPUT ".kernel_noinit.*" )