diff options
author | Jun Lin <CHLin56@nuvoton.com> | 2023-03-13 13:04:33 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-05-05 19:13:28 +0000 |
commit | dc0e942d7c42adc34352c2c7c994f2b067df033d (patch) | |
tree | 300fa93476be1a3618638579709c1b13b7104955 /core | |
parent | 54aa69fd9605d3bc38b410c8918aea9c8378e4f0 (diff) | |
download | chrome-ec-dc0e942d7c42adc34352c2c7c994f2b067df033d.tar.gz |
core/cortex-m: fix __data_lma_start when compiling with clang
The NPCX RO firmware image is composed of the 64-bytes NPCX image header
(start at flash offset 0) + EC firmware image. After the EC chip boots
up, the EC booter copies only the EC image part from the flash to the
CODE RAM. As a result, the value of the __data_lma_start should be
assigned to the end of the VMA of the .rodata section
(0x1008fcb0+0x4cb0=0x10094960) but the start of the LMA of .data
section (0x100949a0). Otherwise, it causes the init.s to copy the
incorrect Right-value to the global variable in the data section.
Sections:
Idx Name Size VMA LMA File off Algn
0 .header 00000040 10080000 10080000 00010000 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .text 0000fcb0 10080000 10080040 00020000 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .rodata 00004cb0 1008fcb0 1008fcf0 0002fcb0 2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .vtable 00000000 200c0000 200c0000 00034960 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .bss 000029f8 200c0000 200c0000 00040000 2**3
ALLOC
5 .data 000001a8 200c29f8 100949a0 000429f8 2**3
CONTENTS, ALLOC, LOAD, DATA
BRANCH=none
BUG=b:271333155
TEST=Verified the EC can run with clang build by David on the helipilot
project.
Change-Id: Ic9b6a2089792242f6a126f6b886536dde4dcd35d
Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4333199
Reviewed-by: CH Lin <chlin56@nuvoton.com>
Tested-by: CH Lin <chlin56@nuvoton.com>
Reviewed-by: David Cross <davidmcross@google.com>
Reviewed-by: Bobby Casey <bobbycasey@google.com>
Tested-by: David Cross <davidmcross@google.com>
Commit-Queue: Bobby Casey <bobbycasey@google.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/cortex-m/ec.lds.S | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/core/cortex-m/ec.lds.S b/core/cortex-m/ec.lds.S index d41a6ff86f..f4133dd890 100644 --- a/core/cortex-m/ec.lds.S +++ b/core/cortex-m/ec.lds.S @@ -382,7 +382,11 @@ SECTIONS * TODO(b/202863352): Unify clang and gcc behavior. */ #ifdef __clang__ +#if defined(SECTION_IS_RO) && defined(NPCX_RO_HEADER) + __data_lma_start = .; +#else __data_lma_start = LOADADDR(.data); +#endif #else __data_lma_start = .; #endif |