diff options
author | Tom Hughes <tomhughes@chromium.org> | 2021-10-11 18:29:50 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-10-13 19:20:30 +0000 |
commit | e2d5e48487158ccfaa3e0e796e7f1da0761b02b0 (patch) | |
tree | 295fc27ab752c61d5a71082f500c5a7337156876 | |
parent | f5f1b176c6104d7b99d4656d19b7a4ad07859a1a (diff) | |
download | chrome-ec-e2d5e48487158ccfaa3e0e796e7f1da0761b02b0.tar.gz |
core/cortex-m: Fix __data_lma_start
Without this change, the code compiles and links when using clang, but
does not boot.
__data_lma_start should be the LMA address of the .data section and is
used in core/cortex-m/init.S to copy the data from the LMA address into
the VMA address (flash to RAM). Before this change, examining the smap
and map files shows that __data_lma_start (0x0800bcdc) does not match
the LMA address of the .data section (0x800bce0):
build/dartmonkey/RO/ec.RO.smap:
0800bcdc R __data_lma_start
build/dartmonkey/RO/ec.RO.map
VMA LMA Size Align Out In Symbol
24003538 800bce0 68 8 .data
After the change, the LMA addresses match and the board boots correctly:
build/dartmonkey/RO/ec.RO.smap:
0800bce0 A __data_lma_start
build/dartmonkey/RO/ec.RO.map
VMA LMA Size Align Out In Symbol
24003538 800bce0 68 8 .data
When comparing the behavior of this change with gcc, we find that many
boards match, but some do not (see TEST line). Looking at a few of the
boards that do not match, there appears to be a one-byte difference in
the RO portion. Investigating further on voxel:
Original address from build/voxel/RO/ec.RO.smap:
100a2e20 R __data_lma_start
New address from build/voxel/RO/ec.RO.smap after applying this change:
100a2e60 A __data_lma_start
In both cases, when using objdump on RO.elf, .data's LMA address starts
at 100a2e60, so this change appears to be correct:
arm-none-eabi-objdump -h
/tmp/compare_build.Ltgh/ec-53a576c00f1b0d609d23a68a83e0340a14ee8fe5/build/voxel/RO/ec.RO.elf
Sections:
Idx Name Size VMA LMA File off Algn
3 .data 00000538 200b8368 100a2e60 00058368 2**3
CONTENTS, ALLOC, LOAD, DATA
arm-none-eabi-objdump -h
/tmp/compare_build.Ltgh/ec-f0c36b07d9efa2f5b12e5de7e794d723e8468e26/build/voxel/RO/ec.RO.elf
Sections:
Idx Name Size VMA LMA File off Algn
5 .data 00000538 200b8368 100a2e60 00058368 2**3
CONTENTS, ALLOC, LOAD, DATA
BRANCH=none
BUG=b:172020503, b:202863352
TEST=make buildall
TEST=make CC=arm-none-eabi-clang BOARD=dartmonkey
TEST=./util/compare_build.sh -b all -j 150
All boards match, EXCEPT:
adlrvpp_npcx akemi aleena ambassador anahera atlas berknip bloog
bobba boldar brask brya bugzzy cappy2 careena casta chronicler
coachz collis copano coral corori dalboz delbin dewatt dirinboz dood
dooly dratini driblee drobit drobit_ecmodeentry eldrid elemi
endeavour eve ezkinil felwinter fizz fleex foob garg genesis gimble
grunt gumboz guybrush hatch helios herobrine_npcx9 homestar jinlon
kano karma kindred kingoftown kohaku lalala lazor liara lick lindar
lux madoo magolor marzipan meep metaknight moonbuggy morphius
mrbland mushu nami nautilus nightfury nipperkin nocturne npcx7_evb
npcx9_evb npcx_evb_arm npcx_evb nuwani palkia pazquel phaser pompom
poppy primus puff quackingstick rammus redrix reef sasuke scout
shuboz soraka stryke taeko treeya trembyle trogdor vilboz voema
volet volteer_npcx797fc voxel voxel_ecmodeentry voxel_npcx797fc
waddledoo2 woomax wormdingler yorp
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: Icd3df244e202a50a577f21ffa4f8202eb3f8b8d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3169964
Reviewed-by: Eric Yilun Lin <yllin@google.com>
Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r-- | core/cortex-m/ec.lds.S | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/cortex-m/ec.lds.S b/core/cortex-m/ec.lds.S index 88fe51a6f3..b099691630 100644 --- a/core/cortex-m/ec.lds.S +++ b/core/cortex-m/ec.lds.S @@ -351,7 +351,7 @@ SECTIONS __data_lma_start = ORIGIN(ROM_RESIDENT_VMA); #define INIT_ROM_LMA (ORIGIN(ROM_RESIDENT_VMA) + SIZEOF(.data)) #else - __data_lma_start = .; + __data_lma_start = LOADADDR(.data); #define INIT_ROM_LMA ORIGIN(ROM_RESIDENT_VMA) #endif |