kernel: init.c: Added required hooks for the relocation
This patch splits the text section into 2 parts. The first section will have some info regarding vector tables and debug info. The second section will have the complete text section. This is needed to force the required functions and data variables the correct locations. This is due to the behavior of the linker. The linker will only link once and hence this text section had to be split to make room for the generated linker script. Added a new Kconfig CODE_DATA_RELOCATION which when enabled will invoke the script, which does the required relocation. Added hooks inside init.c for bss zeroing and data copy operations. Needed when we have to copy data from ROM to required memory type. Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
This commit is contained in:
parent
62e152a8f0
commit
91c5b84cd5
3 changed files with 29 additions and 0 deletions
|
@ -69,6 +69,15 @@ config LINKER_ORPHAN_SECTION_ERROR
|
|||
|
||||
endchoice
|
||||
|
||||
config CODE_DATA_RELOCATION
|
||||
bool "Relocate code/data sections"
|
||||
depends on ARM
|
||||
help
|
||||
When selected this will relocate .text, data and .bss sections from
|
||||
the specified files and places it in the required memory region. The
|
||||
files should be specified in the CMakeList.txt file with
|
||||
a cmake API zephyr_code_relocation().
|
||||
|
||||
config HAS_FLASH_LOAD_OFFSET
|
||||
bool
|
||||
help
|
||||
|
|
|
@ -161,6 +161,16 @@ SECTIONS
|
|||
KEEP(*(".kinetis_flash_config.*"))
|
||||
|
||||
_vector_end = .;
|
||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
|
||||
#ifdef CONFIG_CODE_DATA_RELOCATION
|
||||
|
||||
#include <linker_relocate.ld>
|
||||
|
||||
#endif /* CONFIG_CODE_DATA_RELOCATION */
|
||||
|
||||
SECTION_PROLOGUE(_TEXT_SECTION_NAME_2,,)
|
||||
{
|
||||
_image_text_start = .;
|
||||
*(.text)
|
||||
*(".text.*")
|
||||
|
|
|
@ -147,6 +147,11 @@ void _bss_zero(void)
|
|||
(void)memset(&__ccm_bss_start, 0,
|
||||
((u32_t) &__ccm_bss_end - (u32_t) &__ccm_bss_start));
|
||||
#endif
|
||||
#ifdef CONFIG_CODE_DATA_RELOCATION
|
||||
extern void bss_zeroing_relocation(void);
|
||||
|
||||
bss_zeroing_relocation();
|
||||
#endif /* CONFIG_CODE_DATA_RELOCATION */
|
||||
#ifdef CONFIG_APPLICATION_MEMORY
|
||||
(void)memset(&__app_bss_start, 0,
|
||||
((u32_t) &__app_bss_end - (u32_t) &__app_bss_start));
|
||||
|
@ -171,6 +176,11 @@ void _data_copy(void)
|
|||
(void)memcpy(&__ccm_data_start, &__ccm_data_rom_start,
|
||||
((u32_t) &__ccm_data_end - (u32_t) &__ccm_data_start));
|
||||
#endif
|
||||
#ifdef CONFIG_CODE_DATA_RELOCATION
|
||||
extern void data_copy_xip_relocation(void);
|
||||
|
||||
data_copy_xip_relocation();
|
||||
#endif /* CONFIG_CODE_DATA_RELOCATION */
|
||||
#ifdef CONFIG_APP_SHARED_MEM
|
||||
(void)memcpy(&_app_smem_start, &_app_smem_rom_start,
|
||||
((u32_t) &_app_smem_end - (u32_t) &_app_smem_start));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue