Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion arch.mk
Original file line number Diff line number Diff line change
Expand Up @@ -1282,14 +1282,17 @@ ifeq ($(USE_CLANG),1)
CLANG_NEWLIB_INCLUDE?=$(abspath $(dir $(CLANG_LIBC_A))/../include)

CC=$(CLANG_DRIVER)
LD=$(CLANG_DRIVER)
# Keep clang for compilation, but use the GNU linker driver so linker-script
# LMAs for RAM sections are preserved and objcopy does not emit sparse images.
LD=$(CLANG_GCC_NAME)
AS=$(CLANG_DRIVER)
AR=$(CROSS_COMPILE)ar
OBJCOPY?=$(CROSS_COMPILE)objcopy
SIZE=$(CROSS_COMPILE)size

CFLAGS+=-isystem $(CLANG_NEWLIB_INCLUDE)
CFLAGS+=-DWOLFSSL_NO_ATOMIC -DWOLFSSL_NO_ATOMICS
CFLAGS+=-Wno-unknown-attributes -Wno-error=unknown-attributes
LDFLAGS+=-nostdlib
endif

Expand Down
14 changes: 11 additions & 3 deletions test-app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ LDFLAGS+=-T $(LSCRIPT) -Wl,-gc-sections -Wl,-Map=image.map -nostartfiles

# Setup default objcopy flags
OBJCOPY_FLAGS+=--gap-fill $(FILL_BYTE)
OBJCOPY_IMAGE_FLAGS:=

ifeq ($(USE_CLANG),1)
# Clang-built ARM ELFs can keep RAM sections as loadable segments, and raw
# objcopy output then expands the flash-to-RAM gap into a huge sparse image.
# The app image only needs the flash-backed output sections.
OBJCOPY_IMAGE_FLAGS+=-j .text -j .edidx
endif

ifeq ($(DEBUG_UART),1)
CFLAGS+=-DDEBUG_UART
Expand Down Expand Up @@ -899,15 +907,15 @@ delta-extra-data:LDFLAGS=-Wl,-Map=image.map

image.bin: image.elf
@echo "\t[BIN] $@"
$(Q)$(OBJCOPY) $(OBJCOPY_FLAGS) -O binary $^ $@
$(Q)$(OBJCOPY) $(OBJCOPY_FLAGS) $(OBJCOPY_IMAGE_FLAGS) -O binary $^ $@

image.hex: image.elf
@echo "\t[HEX] $@"
$(Q)$(OBJCOPY) $(OBJCOPY_FLAGS) -O ihex $^ $@
$(Q)$(OBJCOPY) $(OBJCOPY_FLAGS) $(OBJCOPY_IMAGE_FLAGS) -O ihex $^ $@

image.srec: image.elf
@echo "\t[SREC] $@"
$(Q)$(OBJCOPY) $(OBJCOPY_FLAGS) -O srec $^ $@
$(Q)$(OBJCOPY) $(OBJCOPY_FLAGS) $(OBJCOPY_IMAGE_FLAGS) -O srec $^ $@

APP_OBJS := $(patsubst $(WOLFBOOT_LIB_WOLFSSL)/%, \
$(WOLFSSL_LOCAL_OBJDIR)/%, $(APP_OBJS))
Expand Down
Loading