diff options
author | Tom Hughes <tomhughes@chromium.org> | 2021-10-26 23:11:45 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-10-29 20:21:48 +0000 |
commit | 21569acb2d30e1f8bf6fa7656b02b338088f18a7 (patch) | |
tree | 561605bc6db3ea0ea825c75d3894c526541184e9 | |
parent | 1053767af03e18d28912226e1cc74b175657b490 (diff) | |
download | chrome-ec-21569acb2d30e1f8bf6fa7656b02b338088f18a7.tar.gz |
common/firmware_image.lds.S: Add empty text section
Without a text section clang/lld will create one and put it at an
address it selects. Even though the section it creates is empty, if the
LMA is beyond the end of the flash, ec.bin will be too large since the
empty space is filled with 0xFF.
For example, before this change servo_micro's ec.bin is 131075 bytes
instead of 131072 (0x20000) bytes.
Examining the sections, we see the LMA is 0x08020003, which is three
bytes beyond the flash size (0x08000000 + 0x20000 + 0x3):
arm-none-eabi-objdump -h build/servo_micro/ec.obj
Sections:
Idx Name Size VMA LMA File off Algn
...
3 .text 00000000 08014b90 08020003 00024b90 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
...
After this change, servo_micro's ec.bin is the correct size: 131072
(0x20000) bytes.
Now the .text section is at the beginning of flash:
arm-none-eabi-objdump -h build/servo_micro/ec.obj
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 08000000 08000000 000000f4 2**2
ALLOC, READONLY, CODE
...
BRANCH=none
BUG=b:172020503
TEST=./util/compare_build.sh -b all -j 120
=> MATCH
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I48f8019fe6b77f880de0d1a0a4a176b3506f3579
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3248887
Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r-- | common/firmware_image.lds.S | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/common/firmware_image.lds.S b/common/firmware_image.lds.S index e2e34de588..04249367b8 100644 --- a/common/firmware_image.lds.S +++ b/common/firmware_image.lds.S @@ -76,6 +76,15 @@ MEMORY SECTIONS { + /* + * Create empty text section. Without an explicit text section + * clang/lld will create one and put it at an address it selects. Even + * though the section it creates is empty, if the LMA is beyond the end + * of the flash, ec.bin will be too large since the empty space is + * filled with 0xFF. + */ + .text (NOLOAD) : {} + .image.RO : AT(IMAGE_RO_AT) { *(.image.RO) } > FLASH =0xff |