Avoid enforcing alignment on stack for IAR

pull/548/head
Daniele Lacamera 2025-02-27 16:46:26 +01:00
parent 3dc152cf1d
commit a195efe608
4 changed files with 16 additions and 6 deletions

View File

@ -74,6 +74,7 @@ int wolfBot_get_dts_size(void *dts_addr);
# endif
#endif
/* Helpers for memory alignment */
#ifndef XALIGNED
#if defined(__GNUC__) || defined(__llvm__) || \
@ -88,6 +89,13 @@ int wolfBot_get_dts_size(void *dts_addr);
#else
#define XALIGNED(x) /* null expansion */
#endif
/* Don't enforce stack alignment on IAR */
#if defined (__IAR_SYSTEMS_ICC__)
#define XALIGNED_STACK(x)
#else
#define XALIGNED_STACK(x) XALIGNED(x)
#endif
#endif

View File

@ -177,7 +177,7 @@ static const uint32_t wolfboot_magic_trail = WOLFBOOT_MAGIC_TRAIL;
#include <stddef.h>
#include <string.h>
static uint8_t NVM_CACHE[NVM_CACHE_SIZE] __attribute__((aligned(16)));
static uint8_t NVM_CACHE[NVM_CACHE_SIZE] XALIGNED(16)
static int nvm_cached_sector = 0;
static uint8_t get_base_offset(uint8_t *base, uintptr_t off)
{
@ -1344,7 +1344,7 @@ int wolfBoot_fallback_is_possible(void)
#define ENCRYPT_CACHE NVM_CACHE
#else
#ifdef WOLFBOOT_SMALL_STACK
static uint8_t ENCRYPT_CACHE[NVM_CACHE_SIZE] __attribute__((aligned(32)));
static uint8_t ENCRYPT_CACHE[NVM_CACHE_SIZE] XALIGNED(32);
#endif
#endif
#else
@ -1363,7 +1363,7 @@ static int RAMFUNCTION hal_set_key(const uint8_t *k, const uint8_t *nonce)
uint32_t trailer_relative_off = 4;
#if !defined(WOLFBOOT_SMALL_STACK) && !defined(NVM_FLASH_WRITEONCE) && !defined(WOLFBOOT_ENCRYPT_CACHE)
uint8_t ENCRYPT_CACHE[NVM_CACHE_SIZE] __attribute__((aligned(32)));
uint8_t ENCRYPT_CACHE[NVM_CACHE_SIZE] XALIGNED_STACK(32);
#endif
#ifdef MMU
@ -1703,7 +1703,7 @@ int RAMFUNCTION ext_flash_encrypt_write(uintptr_t address, const uint8_t *data,
uint8_t part;
uint32_t iv_counter = 0;
#if defined(EXT_ENCRYPTED) && !defined(WOLFBOOT_SMALL_STACK) && !defined(NVM_FLASH_WRITEONCE)
uint8_t ENCRYPT_CACHE[NVM_CACHE_SIZE] __attribute__((aligned(32)));
uint8_t ENCRYPT_CACHE[NVM_CACHE_SIZE] XALIGNED_STACK(32);
#endif
row_offset = address & (ENCRYPT_BLOCK_SIZE - 1);

View File

@ -79,7 +79,7 @@ extern uint8_t _end_wb[];
*/
void RAMFUNCTION wolfBoot_start(void)
{
uint8_t p_hdr[IMAGE_HEADER_SIZE] __attribute__((aligned(16)));
uint8_t p_hdr[IMAGE_HEADER_SIZE] XALIGN_STACK(16);
struct stage2_parameter *stage2_params;
struct wolfBoot_image os_image;
int pA_ver = 0, pB_ver = 0;

View File

@ -29,7 +29,9 @@
#include <stdint.h>
/* System */
#define WOLFBOOT_KEYTOOLS
#ifndef WOLFBOOT_KEYTOOLS
#define WOLFBOOT_KEYTOOLS
#endif
#define SINGLE_THREADED
#define WOLFCRYPT_ONLY