Skip to content

Commit a195efe

Browse files
committed
Avoid enforcing alignment on stack for IAR
1 parent 3dc152c commit a195efe

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

include/image.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ int wolfBot_get_dts_size(void *dts_addr);
7474
# endif
7575
#endif
7676

77+
7778
/* Helpers for memory alignment */
7879
#ifndef XALIGNED
7980
#if defined(__GNUC__) || defined(__llvm__) || \
@@ -88,6 +89,13 @@ int wolfBot_get_dts_size(void *dts_addr);
8889
#else
8990
#define XALIGNED(x) /* null expansion */
9091
#endif
92+
93+
/* Don't enforce stack alignment on IAR */
94+
#if defined (__IAR_SYSTEMS_ICC__)
95+
#define XALIGNED_STACK(x)
96+
#else
97+
#define XALIGNED_STACK(x) XALIGNED(x)
98+
#endif
9199
#endif
92100

93101

src/libwolfboot.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static const uint32_t wolfboot_magic_trail = WOLFBOOT_MAGIC_TRAIL;
177177

178178
#include <stddef.h>
179179
#include <string.h>
180-
static uint8_t NVM_CACHE[NVM_CACHE_SIZE] __attribute__((aligned(16)));
180+
static uint8_t NVM_CACHE[NVM_CACHE_SIZE] XALIGNED(16)
181181
static int nvm_cached_sector = 0;
182182
static uint8_t get_base_offset(uint8_t *base, uintptr_t off)
183183
{
@@ -1344,7 +1344,7 @@ int wolfBoot_fallback_is_possible(void)
13441344
#define ENCRYPT_CACHE NVM_CACHE
13451345
#else
13461346
#ifdef WOLFBOOT_SMALL_STACK
1347-
static uint8_t ENCRYPT_CACHE[NVM_CACHE_SIZE] __attribute__((aligned(32)));
1347+
static uint8_t ENCRYPT_CACHE[NVM_CACHE_SIZE] XALIGNED(32);
13481348
#endif
13491349
#endif
13501350
#else
@@ -1363,7 +1363,7 @@ static int RAMFUNCTION hal_set_key(const uint8_t *k, const uint8_t *nonce)
13631363
uint32_t trailer_relative_off = 4;
13641364

13651365
#if !defined(WOLFBOOT_SMALL_STACK) && !defined(NVM_FLASH_WRITEONCE) && !defined(WOLFBOOT_ENCRYPT_CACHE)
1366-
uint8_t ENCRYPT_CACHE[NVM_CACHE_SIZE] __attribute__((aligned(32)));
1366+
uint8_t ENCRYPT_CACHE[NVM_CACHE_SIZE] XALIGNED_STACK(32);
13671367
#endif
13681368

13691369
#ifdef MMU
@@ -1703,7 +1703,7 @@ int RAMFUNCTION ext_flash_encrypt_write(uintptr_t address, const uint8_t *data,
17031703
uint8_t part;
17041704
uint32_t iv_counter = 0;
17051705
#if defined(EXT_ENCRYPTED) && !defined(WOLFBOOT_SMALL_STACK) && !defined(NVM_FLASH_WRITEONCE)
1706-
uint8_t ENCRYPT_CACHE[NVM_CACHE_SIZE] __attribute__((aligned(32)));
1706+
uint8_t ENCRYPT_CACHE[NVM_CACHE_SIZE] XALIGNED_STACK(32);
17071707
#endif
17081708

17091709
row_offset = address & (ENCRYPT_BLOCK_SIZE - 1);

src/update_disk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ extern uint8_t _end_wb[];
7979
*/
8080
void RAMFUNCTION wolfBoot_start(void)
8181
{
82-
uint8_t p_hdr[IMAGE_HEADER_SIZE] __attribute__((aligned(16)));
82+
uint8_t p_hdr[IMAGE_HEADER_SIZE] XALIGN_STACK(16);
8383
struct stage2_parameter *stage2_params;
8484
struct wolfBoot_image os_image;
8585
int pA_ver = 0, pB_ver = 0;

tools/keytools/user_settings.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
#include <stdint.h>
3030

3131
/* System */
32-
#define WOLFBOOT_KEYTOOLS
32+
#ifndef WOLFBOOT_KEYTOOLS
33+
#define WOLFBOOT_KEYTOOLS
34+
#endif
3335
#define SINGLE_THREADED
3436
#define WOLFCRYPT_ONLY
3537

0 commit comments

Comments
 (0)