summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorYilun Lin <yllin@google.com>2019-03-11 14:00:40 +0800
committerchrome-bot <chrome-bot@chromium.org>2019-03-18 12:53:29 -0700
commit6c022cf36fb039f6edcf3c22d0a1a0ea9e4f0fae (patch)
tree79158780ae5db289b115500529201867c95c89b7 /core
parentb5366bcd54fbe92ea77db6d2d6d981f65568880e (diff)
downloadchrome-ec-6c022cf36fb039f6edcf3c22d0a1a0ea9e4f0fae.tar.gz
cortex-m/ec.ld.S: Remove explicitly allocated .data LMA sections.
Overlapping LMA section with other VMA section will fail lld. This CL makes the linker script to be compatible with both ld and lld. BRANCH=None BUG=b:128269393 TEST=On m/master; make buildall -j; mv build build.old After this CL: make buildall -j ls build/*/*/ec.*.smap | sed -e 's|build/||' | \ xargs -I{} diff build/{} build.old/{} => no difference except that __data_lma_start's attribute changes from D to R. e.g., 0011a4a0 D __data_lma_start becomse 0011a4a0 R __data_lma_start TEST=diff build/kukui_scp/RW/ec.RW.flat build.old/kukui_scp/RW/ec.RW.flat are the same, except the version strings. TEST=CC=clang make BOARD=kukui_scp and see that __bss_start and __data_lma_start not overlapping in kukui_scp/RW/ec.RW.smap TEST=CC=clang make BOARD=nocturne_fp -j and build pass. Change-Id: I4a6ece8d2279124e2797e0dc71b228a470f029d9 Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1514436 Commit-Ready: Tom Hughes <tomhughes@chromium.org> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/cortex-m/ec.lds.S43
1 files changed, 23 insertions, 20 deletions
diff --git a/core/cortex-m/ec.lds.S b/core/cortex-m/ec.lds.S
index 28c3e691cd..8a20fe931a 100644
--- a/core/cortex-m/ec.lds.S
+++ b/core/cortex-m/ec.lds.S
@@ -272,26 +272,25 @@ SECTIONS
} > FLASH
#endif
- .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;
+ __data_lma_start = .;
+
#if !defined(CONFIG_FLASH_PHYSICAL)
- } > IRAM
-#elif defined(CONFIG_EXTERNAL_STORAGE)
- } > CDRAM AT > FLASH
+ /*
+ * Make a space for .data section's LMA. Otherwise, ld won't preserve
+ * a space for .data if .rodata and .bss sections are both in IRAM.
+ */
+#if defined(__clang__)
+ /*
+ * The lazy evaluation timing of symbols and builtin functions of ld and
+ * lld are different.
+ */
+ .bss __data_lma_start + SIZEOF(.data) : {
+#else
+ .bss __data_lma_start + __data_end - __data_start : {
+#endif /* __clang__ */
#else
- } > FLASH
-#endif
-
.bss : {
+#endif /* !CONFIG_FLASH_PHYSICAL */
/*
* Align to 512 bytes. This is convenient when some memory block
* needs big alignment. This is the beginning of the RAM, so there
@@ -346,9 +345,9 @@ SECTIONS
#endif /* defined(CONFIG_REPLACE_LOADER_WITH_BSS_SLOW) */
#ifdef CONFIG_EXTERNAL_STORAGE
- .data : AT(LOADADDR(.data_lma)) {
+ .data : AT(LOADADDR(.rodata) + SIZEOF(.rodata)) {
#else
- .data : AT(ADDR(.data_lma)) {
+ .data : AT(ADDR(.rodata) + SIZEOF(.rodata)) {
#endif
. = ALIGN(4);
__data_start = .;
@@ -444,7 +443,11 @@ SECTIONS
#endif /* CONFIG_CHIP_MEMORY_REGIONS */
#ifdef CONFIG_DRAM_BASE
- /* Allocate space for original copy of .data.dram (see .data_lma above). */
+ /*
+ * Allocate space for original copy of .data.dram (see .data_lma above).
+ * TODO(b:128269393): Remove .dram.data_lma sections to be compatible
+ * with clang.
+ */
.dram.data_lma : {
__dram_data_lma_start = .;
. += __dram_data_end - __dram_data_start;