From 216ab1e1d8d74bc722d3e322b2460802e93a5df9 Mon Sep 17 00:00:00 2001 From: Yilun Lin Date: Wed, 12 Dec 2018 19:14:39 +0800 Subject: core/cortex-m: Support prevent chip memory region from GC. We would like to keep a symbol in a chip memory region from GC in link time. However __attribute__((used)) cannot fulfill the requirement in such situation. This CL adds a "name.keep" section to prevent all the symbols in this section in a chip memory region from GC. Also, we would like to support a non-NOLOAD section, which can load default value on runtime. BUG=b:120825336 TEST=make buildall -j BRANCH=none Change-Id: I76cf445f6b4c0b61c20182a1aaf5a44f962049ae Signed-off-by: Yilun Lin Reviewed-on: https://chromium-review.googlesource.com/1373949 Commit-Ready: ChromeOS CL Exonerator Bot Tested-by: Yilun Lin Reviewed-by: Nicolas Boichat --- core/cortex-m/ec.lds.S | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'core/cortex-m') diff --git a/core/cortex-m/ec.lds.S b/core/cortex-m/ec.lds.S index dabdedf860..2a9a9b2fe0 100644 --- a/core/cortex-m/ec.lds.S +++ b/core/cortex-m/ec.lds.S @@ -59,8 +59,10 @@ MEMORY #ifdef CONFIG_CHIP_MEMORY_REGIONS #define REGION(name, attr, start, size) \ name(attr) : ORIGIN = (start), LENGTH = (size) +#define REGION_LOAD REGION #include "memory_regions.inc" #undef REGION +#undef REGION_LOAD #endif /* CONFIG_MEMORY_REGIONS */ } SECTIONS @@ -406,10 +408,18 @@ SECTIONS #define REGION(name, attr, start, size) \ .name(NOLOAD) : { \ __##name##_start = .; \ + KEEP(*(SORT(.name.keep.*))) \ + *(SORT(.name.*)) \ + } > name +#define REGION_LOAD(name, attr, start, size) \ + .name : { \ + __##name##_start = .; \ + KEEP(*(SORT(.name.keep.*))) \ *(SORT(.name.*)) \ } > name #include "memory_regions.inc" #undef REGION +#undef REGION_LOAD #endif /* CONFIG_CHIP_MEMORY_REGIONS */ #if !(defined(SECTION_IS_RO) && defined(CONFIG_FLASH)) -- cgit v1.2.1