File tree Expand file tree Collapse file tree 3 files changed +25
-7
lines changed
Expand file tree Collapse file tree 3 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -198,9 +198,11 @@ ifeq ($(USE_GCC_HEADLESS),1)
198198 OBJCOPY_FLAGS+ =--gap-fill $(FILL_BYTE )
199199endif
200200
201- ifeq ($(USE_CLANG ) ,1)
202- ifeq ($(ARCH),ARM)
203- OBJCOPY_BIN_FLAGS+ =$(CLANG_ARM_OBJCOPY_FLASH_FLAGS_BOOT )
201+ ifeq ($(ARCH ) ,ARM)
202+ ifeq ($(USE_CLANG),1)
203+ ifneq ($(TZEN),1)
204+ OBJCOPY_BIN_FLAGS+ =$(CLANG_ARM_OBJCOPY_FLASH_FLAGS_BOOT )
205+ endif
204206 endif
205207endif
206208ifeq ($(TARGET ) ,ti_hercules)
@@ -329,7 +331,21 @@ wolfboot.efi: wolfboot.elf
329331
330332wolfboot.bin : wolfboot.elf
331333 @echo " \t[BIN] $@ "
334+ ifeq ($(USE_CLANG ) ,1)
335+ ifeq ($(TZEN ) ,1)
336+ $(Q)last_load="$$($(CROSS_COMPILE)readelf -Wl $< | awk '/ LOAD / { line = $$0 } END { print line }')"; \
337+ set -- $$last_load; \
338+ last_phys=$$(printf '%d' $$4); \
339+ last_filesz=$$(printf '%d' $$5); \
340+ padded_filesz=$$((($$last_filesz + 0xff) & ~0xff)); \
341+ pad_to=$$((last_phys + padded_filesz)); \
342+ $(OBJCOPY) $(OBJCOPY_FLAGS) $(OBJCOPY_BIN_FLAGS) --pad-to=$$(printf '0x%x' $$pad_to) -O binary $< $@
343+ else
332344 $(Q)$(OBJCOPY) $(OBJCOPY_FLAGS) $(OBJCOPY_BIN_FLAGS) -O binary $^ $@
345+ endif
346+ else
347+ $(Q)$(OBJCOPY) $(OBJCOPY_FLAGS) $(OBJCOPY_BIN_FLAGS) -O binary $^ $@
348+ endif
333349 @echo
334350 @echo "\t[SIZE]"
335351 $(Q)$(SIZE) wolfboot.elf
Original file line number Diff line number Diff line change @@ -1295,9 +1295,9 @@ ifeq ($(USE_CLANG),1)
12951295 CFLAGS+ =-Wno-unknown-attributes -Wno-error=unknown-attributes
12961296 CFLAGS+ =-fno-unwind-tables -fno-asynchronous-unwind-tables
12971297 LSCRIPT_FLAGS+ =-T $(abspath $(WOLFBOOT_ROOT ) /hal/clang-discard.ld)
1298- # Keep Clang-specific raw-image section selection in one place. Both the
1299- # bootloader and test-app need flash-backed sections only, but the bootloader
1300- # has a few extra output sections that must be preserved .
1298+ # Clang-built ARM raw images may otherwise expand ELF loadable gaps into
1299+ # oversized binaries on some targets. Keep the section selection scoped to
1300+ # the Clang workaround paths only .
13011301 CLANG_ARM_OBJCOPY_FLASH_FLAGS_BASE: =-j .text -j .edidx
13021302 CLANG_ARM_OBJCOPY_FLASH_FLAGS_BOOT: =$(CLANG_ARM_OBJCOPY_FLASH_FLAGS_BASE ) -j .ramcode -j .keystore -j .gnu.sgstubs
13031303 CLANG_ARM_OBJCOPY_FLASH_FLAGS_APP: =$(CLANG_ARM_OBJCOPY_FLASH_FLAGS_BASE )
Original file line number Diff line number Diff line change @@ -108,7 +108,9 @@ ifeq ($(USE_CLANG),1)
108108 # Clang-built ARM ELFs can keep RAM sections as loadable segments, and raw
109109 # objcopy output then expands the flash-to-RAM gap into a huge sparse image.
110110 # The app image only needs the flash-backed output sections.
111- OBJCOPY_IMAGE_FLAGS+ =$(CLANG_ARM_OBJCOPY_FLASH_FLAGS_APP )
111+ ifneq ($(TZEN),1)
112+ OBJCOPY_IMAGE_FLAGS+ =$(CLANG_ARM_OBJCOPY_FLASH_FLAGS_APP )
113+ endif
112114endif
113115
114116ifeq ($(DEBUG_UART ) ,1)
You can’t perform that action at this time.
0 commit comments