summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2021-10-25 18:20:17 +0000
committerCommit Bot <commit-bot@chromium.org>2021-11-03 23:00:01 +0000
commitdcc080eeeee889be594af9fb20a1344de5d2cbc7 (patch)
treed1f29e1347a4c836f1561105356431dd98e780b1
parentc55ec606e81674df19e26b364ab7550c1a4da5f8 (diff)
downloadchrome-ec-dcc080eeeee889be594af9fb20a1344de5d2cbc7.tar.gz
chip/npcx: Fix monitor compilation with clang
Disable LTO when compiling the monitor header since clang will generate an LLVM IR bitcode file instead of an ARM object file. objcopy then fails since it doesn't recognize the file type. This shouldn't result in any loss of optimization since these are single .c files that are not being linked. Also add a DISCARD section in the linker script to fix the clang (lld) warning: ld.lld: error: no memory region specified for section '.ARM.exidx' This should be safe since there is no ".ARM.exidx" section in npcx_monitor.elf generated by gcc before this change as shown by arm-none-eabi-objdump -h build/brya/chip/npcx/spiflashfw/npcx_monitor.elf Go ahead and discard any other ".ARM.*" sections as well since we do that in our other EC linker scripts. Details on these sections can be found in https://developer.arm.com/documentation/ihi0044/h/?lang=en#sections under the "Sections" section. 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: I784d7a9e69989b330f58f89ae3a901d459e7cd21 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3243010 Reviewed-by: Edward Hill <ecgh@chromium.org>
-rw-r--r--Makefile.rules4
-rw-r--r--chip/npcx/spiflashfw/npcx_monitor.ld1
2 files changed, 3 insertions, 2 deletions
diff --git a/Makefile.rules b/Makefile.rules
index 91182a3a58..bf621f0191 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -670,14 +670,14 @@ $(npcx-monitor-fw-bin):$(npcx-monitor-fw).c npx-monitor-dir
$(Q)$(OBJCOPY) -O binary $(out)/$(npcx-monitor-fw).elf $@
$(out)/$(npcx-monitor-hdr)_ro.o:$(npcx-monitor-hdr).c npx-monitor-dir
- $(Q)$(CC) $(CFLAGS) -DSECTION_IS_RO=$(EMPTY) -MMD -c $< -MT $@ -o $@
+ $(Q)$(CC) $(CFLAGS) -DSECTION_IS_RO=$(EMPTY) -MMD -fno-lto -c $< -MT $@ -o $@
$(npcx-monitor-hdr-ro-bin):$(out)/$(npcx-monitor-hdr)_ro.o
$(if $(V),,@echo ' EXTBIN ' $(subst $(out)/,,$@) ; )
$(Q)$(OBJCOPY) -O binary $< $@
$(out)/$(npcx-monitor-hdr)_rw.o:$(npcx-monitor-hdr).c npx-monitor-dir
- $(Q)$(CC) $(CFLAGS) -MMD -c $< -MT $@ -o $@
+ $(Q)$(CC) $(CFLAGS) -MMD -fno-lto -c $< -MT $@ -o $@
$(npcx-monitor-hdr-rw-bin):$(out)/$(npcx-monitor-hdr)_rw.o
$(if $(V),,@echo ' EXTBIN ' $(subst $(out)/,,$@) ; )
diff --git a/chip/npcx/spiflashfw/npcx_monitor.ld b/chip/npcx/spiflashfw/npcx_monitor.ld
index 03e38b0609..ae7760c519 100644
--- a/chip/npcx/spiflashfw/npcx_monitor.ld
+++ b/chip/npcx/spiflashfw/npcx_monitor.ld
@@ -49,4 +49,5 @@ SECTIONS
*/
_sidata = _etext;
+ /DISCARD/ : { *(.ARM.*) }
}