Skip to content

Commit 3697f9e

Browse files
committed
image: use portable noinline macro
F/2273
1 parent 63466db commit 3697f9e

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

include/image.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ struct wolfBoot_image {
166166
* With ARMORED setup, the flag is redundant, and the information is wrapped in
167167
* between canary variables, to mitigate attacks based on memory corruptions.
168168
*/
169-
static void __attribute__((noinline)) wolfBoot_image_confirm_signature_ok(
169+
static void NOINLINEFUNCTION wolfBoot_image_confirm_signature_ok(
170170
struct wolfBoot_image *img)
171171
{
172172
img->canary_FEED4567 = 0xFEED4567UL;
@@ -176,7 +176,7 @@ static void __attribute__((noinline)) wolfBoot_image_confirm_signature_ok(
176176
img->canary_FEED89AB = 0xFEED89ABUL;
177177
}
178178

179-
static void __attribute__((noinline)) wolfBoot_image_clear_signature_ok(
179+
static void NOINLINEFUNCTION wolfBoot_image_clear_signature_ok(
180180
struct wolfBoot_image *img)
181181
{
182182
img->canary_FEED4567 = 0xFEED4567UL;

include/wolfboot/wolfboot.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,20 @@ extern "C" {
8383
# endif
8484
#endif
8585

86+
#ifndef NOINLINEFUNCTION
87+
# if defined(__has_attribute)
88+
# if __has_attribute(noinline)
89+
# define NOINLINEFUNCTION __attribute__((noinline))
90+
# else
91+
# define NOINLINEFUNCTION
92+
# endif
93+
# elif defined(__GNUC__) || defined(__CC_ARM)
94+
# define NOINLINEFUNCTION __attribute__((noinline))
95+
# else
96+
# define NOINLINEFUNCTION
97+
# endif
98+
#endif
99+
86100

87101
/* Helpers for memory alignment */
88102
#ifndef XALIGNED

src/image.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
/* Globals */
5959
static uint8_t digest[WOLFBOOT_SHA_DIGEST_SIZE] XALIGNED(4);
6060

61-
int __attribute__((noinline)) image_CT_compare(
61+
int NOINLINEFUNCTION image_CT_compare(
6262
const uint8_t *expected, const uint8_t *actual, uint32_t len)
6363
{
6464
uint8_t diff = 0;

0 commit comments

Comments
 (0)