diff options
author | Yilun Lin <yllin@google.com> | 2019-01-10 17:10:58 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-01-29 17:45:51 -0800 |
commit | 39d895712f22d340b885c4651b5c99f6dda40c7c (patch) | |
tree | 184075f9d222a2ff1595b1870a5882710396655e /core/cortex-m | |
parent | 54892b6f9ce0da0205b81586a042a8c36674a53a (diff) | |
download | chrome-ec-39d895712f22d340b885c4651b5c99f6dda40c7c.tar.gz |
cortex/cortex-m/ec.lds.S: Preserve space for .data section's LMA.
If .text, .rodata and .bss section are all puts in the same memory
space, e.g. RAM (.data section's LMA is usually located right
after .rodata section, and right before .bss section.).
.data section's LMA might be overlapped with .bss section so that
it would get cleared to zero on program startup.
TEST=Remove ". = ALIGN(512);" in .bss section in linker script,
and check build/kukui_scp/RW/ec.RW.smap, and we have
__data_lma_start = 0x74b4
__bss_start = 0x74f8
__data_start = 0x8ae0
__data_end = 0x8b20
__data_end - __data_start = 64
__bss_start - __data_lma_start = 68 # .data is able to fit in.
check .data section LMA won't be overlapped with .bss section VMA.
BUG=b:122084384
BRANCH=None
Change-Id: Ic6ae7ad7c6a080ce7aa6375c4f0e01ac9474cdc7
Signed-off-by: Yilun Lin <yllin@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1404640
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Yilun Lin <yllin@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'core/cortex-m')
-rw-r--r-- | core/cortex-m/ec.lds.S | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/core/cortex-m/ec.lds.S b/core/cortex-m/ec.lds.S index ef0a2a2dc9..07c38a0052 100644 --- a/core/cortex-m/ec.lds.S +++ b/core/cortex-m/ec.lds.S @@ -271,7 +271,25 @@ SECTIONS #else } > FLASH #endif - __data_lma_start = . ; + + .data_lma : { + /* + * Explicitly allocate a space for .data section LMA. Linker should + * be able to do this while linking, but it doesn't guarantee LMV/VMA + * might be overlapped. This is a trick to prevent .bss section + * overlapped with .data's LMA (This could happen if .rodata and .bss + * are in the same memory region, e.g. IRAM), so .data LMA might get + * cleared on program starting up. + */ + __data_lma_start = .; + . += __data_end - __data_start; +#if !defined(CONFIG_FLASH_PHYSICAL) + } > IRAM +#elif defined(CONFIG_EXTERNAL_STORAGE) + } > CDRAM AT > FLASH +#else + } > FLASH +#endif .bss : { /* @@ -329,9 +347,9 @@ SECTIONS #endif /* defined(CONFIG_REPLACE_LOADER_WITH_BSS_SLOW) */ #ifdef CONFIG_EXTERNAL_STORAGE - .data : AT(LOADADDR(.rodata) + SIZEOF(.rodata)) { + .data : AT(LOADADDR(.data_lma)) { #else - .data : AT(ADDR(.rodata) + SIZEOF(.rodata)) { + .data : AT(ADDR(.data_lma)) { #endif . = ALIGN(4); __data_start = .; |