From 09303f7f680dfef4ccbd38babb66361018c22f07 Mon Sep 17 00:00:00 2001 From: Benjamin Walsh Date: Wed, 16 Sep 2015 19:14:40 -0400 Subject: [PATCH] linker scripts: add symbols for ROM/RAM boundaries These symbols have more meaningful names when trying to figure out where the ROM/RAM starts/ends, rather than relying on e.g. __data_rom_start for the end of the ROM (__data_rom_start is the beginning of the data in ROM, thus is not part of the image). Change-Id: I4aa0354ee414fd0d46d0f40952e091ba090e7bce Signed-off-by: Benjamin Walsh --- include/arch/arm/cortex_m/scripts/linker.cmd | 5 +++++ include/arch/x86/linker-common-sections.h | 6 ++++++ include/linker-defs.h | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/include/arch/arm/cortex_m/scripts/linker.cmd b/include/arch/arm/cortex_m/scripts/linker.cmd index 6f9ab768424..a1004e34c6e 100644 --- a/include/arch/arm/cortex_m/scripts/linker.cmd +++ b/include/arch/arm/cortex_m/scripts/linker.cmd @@ -65,6 +65,8 @@ SECTIONS { GROUP_START(ROMABLE_REGION) + _image_rom_start = CONFIG_FLASH_BASE_ADDRESS; + SECTION_PROLOGUE(_TEXT_SECTION_NAME,,) { KEEP(*(.exc_vector_table)) @@ -133,6 +135,7 @@ SECTIONS *(".rodata.*") } GROUP_LINK_IN(ROMABLE_REGION) + _image_rom_end = .; __data_rom_start = ALIGN(4); /* XIP imaged DATA ROM start addr */ GROUP_END(ROMABLE_REGION) @@ -145,6 +148,7 @@ SECTIONS SECTION_PROLOGUE(_DATA_SECTION_NAME,,) #endif { + _image_ram_start = .; __data_ram_start = .; *(.data) *(".data.*") @@ -244,6 +248,7 @@ SECTIONS /* Define linker symbols */ + _image_ram_end = .; _end = .; /* end of image */ __bss_num_words = (__bss_end - __bss_start) >> 2; diff --git a/include/arch/x86/linker-common-sections.h b/include/arch/x86/linker-common-sections.h index f80edea346a..9e1be632b32 100644 --- a/include/arch/x86/linker-common-sections.h +++ b/include/arch/x86/linker-common-sections.h @@ -63,8 +63,11 @@ SECTIONS { GROUP_START(ROMABLE_REGION) + _image_rom_start = PHYS_LOAD_ADDR; + SECTION_PROLOGUE(_TEXT_SECTION_NAME, (OPTIONAL),) { + *(.text_start) *(".text_start.*") *(.text) @@ -110,6 +113,7 @@ SECTIONS KEXEC_PGALIGN_PAD(MMU_PAGE_SIZE) } GROUP_LINK_IN(ROMABLE_REGION) + _image_rom_end = .; __data_rom_start = ALIGN(4); /* XIP imaged DATA ROM start addr */ GROUP_END(ROMABLE_REGION) @@ -124,6 +128,7 @@ SECTIONS #endif { KEXEC_PGALIGN_PAD(MMU_PAGE_SIZE) + _image_ram_start = .; __data_ram_start = .; *(.data) *(".data.*") @@ -231,6 +236,7 @@ SECTIONS } GROUP_LINK_IN(RAM) /* Define linker symbols */ + _image_ram_end = .; _end = .; /* end of image */ . = ALIGN(MMU_PAGE_SIZE); diff --git a/include/linker-defs.h b/include/linker-defs.h index 50f5846d5df..00382f651f1 100644 --- a/include/linker-defs.h +++ b/include/linker-defs.h @@ -113,6 +113,11 @@ extern char __data_ram_start[]; extern int __data_num_words[]; #endif +extern char _image_rom_start[]; +extern char _image_rom_end[]; +extern char _image_ram_start[]; +extern char _image_ram_end[]; + /* end address of image. */ extern char _end[];