Skip to content

Commit 58c2e04

Browse files
authored
Merge pull request #730 from danielinux/clang-linker
Fix embedded images built with the clang compiler
2 parents 9fa443f + 941d3f2 commit 58c2e04

23 files changed

+138
-19
lines changed

.github/workflows/test-build.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
build:
2020
runs-on: ubuntu-latest
2121
container:
22-
image: ghcr.io/wolfssl/wolfboot-ci-arm:v1.0
22+
image: ghcr.io/wolfssl/wolfboot-ci-arm:v1.3
2323
timeout-minutes: 30
2424

2525
steps:
@@ -45,3 +45,18 @@ jobs:
4545
- name: Build wolfboot
4646
run: |
4747
make ${{inputs.make-args}}
48+
49+
- name: Rebuild wolfboot with Clang
50+
if: |
51+
inputs.config-file == './config/examples/stm32h7.config' ||
52+
inputs.config-file == './config/examples/stm32h7-octospi.config' ||
53+
inputs.config-file == './config/examples/stm32u5.config' ||
54+
inputs.config-file == './config/examples/stm32u5-wolfcrypt-tz.config' ||
55+
inputs.config-file == './config/examples/stm32u5-nonsecure-dualbank.config' ||
56+
inputs.config-file == './config/examples/stm32n6.config' ||
57+
inputs.config-file == './config/examples/stm32n6-tz.config'
58+
run: |
59+
make distclean
60+
cp ${{inputs.config-file}} .config
61+
make -C tools/keytools && make -C tools/bin-assemble
62+
make USE_CLANG=1 USE_GCC=0 ${{inputs.make-args}}

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ OBJS:= \
4242
./src/libwolfboot.o \
4343
./hal/hal.o
4444

45+
ifeq ($(USE_CLANG),1)
46+
OBJS+=./src/clang_sections.o
47+
endif
48+
4549
ifeq ($(WOLFCRYPT_TZ_PSA),1)
4650
OBJS+=./src/dice/dice.o
4751
endif
@@ -197,6 +201,7 @@ ifeq ($(USE_GCC_HEADLESS),1)
197201
LSCRIPT_FLAGS+=-T $(LSCRIPT)
198202
OBJCOPY_FLAGS+=--gap-fill $(FILL_BYTE)
199203
endif
204+
200205
ifeq ($(TARGET),ti_hercules)
201206
LSCRIPT_FLAGS+=--run_linker $(LSCRIPT)
202207
endif

arch.mk

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,14 +1288,16 @@ ifeq ($(USE_CLANG),1)
12881288
CLANG_NEWLIB_INCLUDE?=$(abspath $(dir $(CLANG_LIBC_A))/../include)
12891289

12901290
CC=$(CLANG_DRIVER)
1291-
LD=$(CLANG_DRIVER)
1291+
LD=$(CLANG_DRIVER) -fuse-ld=lld
12921292
AS=$(CLANG_DRIVER)
1293-
AR=$(CROSS_COMPILE)ar
1294-
OBJCOPY?=$(CROSS_COMPILE)objcopy
1295-
SIZE=$(CROSS_COMPILE)size
1293+
AR=llvm-ar
1294+
OBJCOPY?=llvm-objcopy
1295+
SIZE=llvm-size
12961296

12971297
CFLAGS+=-isystem $(CLANG_NEWLIB_INCLUDE)
12981298
CFLAGS+=-DWOLFSSL_NO_ATOMIC -DWOLFSSL_NO_ATOMICS
1299+
CFLAGS+=-Wno-unknown-attributes -Wno-error=unknown-attributes
1300+
CFLAGS+=-fno-unwind-tables -fno-asynchronous-unwind-tables
12991301
LDFLAGS+=-nostdlib
13001302
endif
13011303

hal/lpc55s69.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ SECTIONS
3030
*(.ARM.exidx*)
3131
} > FLASH
3232

33-
.gnu.sgstubs :
33+
.gnu.sgstubs ORIGIN(FLASH_NSC) :
3434
{
3535
. += 0x400;
3636
. = ALIGN(4);

hal/mcxn.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ SECTIONS
3030
*(.ARM.exidx*)
3131
} > FLASH
3232

33-
.gnu.sgstubs :
33+
.gnu.sgstubs ORIGIN(FLASH_NSC) :
3434
{
3535
. += 0x400;
3636
. = ALIGN(4);

hal/mcxw.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ SECTIONS
3030
*(.ARM.exidx*)
3131
} > FLASH
3232

33-
.gnu.sgstubs :
33+
.gnu.sgstubs ORIGIN(FLASH_NSC) :
3434
{
3535
. += 0x400;
3636
. = ALIGN(4);

hal/nrf5340-ns.ld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ SECTIONS
2626
*(.ARM.exidx*)
2727
} > FLASH
2828

29+
.keystore :
30+
{
31+
. = ALIGN(4);
32+
KEEP(*(.keystore*))
33+
} > FLASH
34+
2935
_stored_data = .;
3036

3137
.data : AT (_stored_data)

hal/nrf5340.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ SECTIONS
2929
*(.ARM.exidx*)
3030
} > FLASH
3131

32-
.gnu.sgstubs :
32+
.gnu.sgstubs ORIGIN(FLASH_NSC) :
3333
{
3434
. += 0x400;
3535
. = ALIGN(4);

hal/nrf54l-ns.ld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ SECTIONS
2525
*(.ARM.exidx*)
2626
} > FLASH
2727

28+
.keystore :
29+
{
30+
. = ALIGN(4);
31+
KEEP(*(.keystore*))
32+
} > FLASH
33+
2834
_stored_data = .;
2935

3036
.data : AT (_stored_data)

hal/nrf54l.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ SECTIONS
2929
*(.ARM.exidx*)
3030
} > FLASH
3131

32-
.gnu.sgstubs :
32+
.gnu.sgstubs ORIGIN(FLASH_NSC) :
3333
{
3434
. += 0x400;
3535
. = ALIGN(4);

0 commit comments

Comments
 (0)