summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2022-10-21 11:23:38 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-11-01 17:57:09 +0000
commit84b2904dead700e10073080c54e69ea162d8a7c5 (patch)
tree0c6746ca3200dab3fb1208cfd03d90f08b14430f
parent82548740a8e9bfff0f65b47b8b18c2497029b223 (diff)
downloadchrome-ec-84b2904dead700e10073080c54e69ea162d8a7c5.tar.gz
core/cortex-m: Add .init_array to .ro_data
When trying to build a unit test that links against googletest, we get the following errors: ld.lld: error: section '.image.RO' will not fit in region 'FLASH': overflowed by 811597840 bytes ld.lld: error: section '.image.RO.key' will not fit in region 'FLASH': overflowed by 811597840 bytes ld.lld: error: section '.image.RO.key' will not fit in region 'FLASH': overflowed by 811598672 bytes ld.lld: error: section '.image.ROLLBACK' will not fit in region 'FLASH': overflowed by 811598672 bytes ld.lld: error: section '.image.ROLLBACK' will not fit in region 'FLASH': overflowed by 811598716 bytes Looking at the sections in the ELF file, we see that .init_array is being put at a really large address: armv7m-cros-eabi-objdump -h \ ./build/dartmonkey/fpsensor_hw/RW/fpsensor_hw.RW.elf Sections: Idx Name Size VMA LMA File off Algn 10 .init_array 0000000c 38800000 38800000 000b0000 2**2 CONTENTS, ALLOC, LOAD, DATA 11 .init_array.100 00000004 3880000c 3880000c 000b000c 2**2 .init_array consists of read-only data (const data array of self-relative pointers to functions), so it can go in the .ro_data section. See https://developer.arm.com/documentation/dui0475/c/the-arm-c-and-c---libraries/c---initialization--construction-and-destruction for details. BRANCH=none BUG=b:234181908, b:254530679 TEST=make BOARD=dartmonkey test-fpsensor_hw -j TEST=./util/compare_build.sh -b all -j 120 => MATCH Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: If6566763452e3f5f87767b0f4999d6db8e6c1572 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3971946 Reviewed-by: Andrea Grandi <agrandi@google.com>
-rw-r--r--core/cortex-m/ec.lds.S7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/cortex-m/ec.lds.S b/core/cortex-m/ec.lds.S
index f5679a97f6..8ea35911df 100644
--- a/core/cortex-m/ec.lds.S
+++ b/core/cortex-m/ec.lds.S
@@ -347,6 +347,13 @@ SECTIONS
. = ALIGN(64);
KEEP(*(.google))
#endif
+
+ /*
+ * https://developer.arm.com/documentation/dui0475/c/the-arm-c-and-c---libraries/c---initialization--construction-and-destruction
+ */
+ . = ALIGN(4);
+ *(.init_array*)
+
/*
* Empty C++ exception index table. The exception index
* table is described in more detail in "Exception Handling