Skip to content

Commit bec5dc2

Browse files
committed
Update to use linker script for bootloader region to measure
1 parent c2d2ded commit bec5dc2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/tpm.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,20 @@ static int TPM2_IoCb(TPM2_CTX* ctx, const uint8_t* txBuf, uint8_t* rxBuf,
235235
#define SELF_HASH_ADDR ((uintptr_t)WOLFBOOT_PARTITION_BOOT_ADDRESS)
236236
#define SELF_HASH_SZ ((uint32_t)WOLFBOOT_PARTITION_SIZE)
237237
#endif
238-
#else
239-
/* Default: measure wolfBoot's own code region
240-
* (from ARCH_FLASH_OFFSET to WOLFBOOT_PARTITION_BOOT_ADDRESS) */
238+
#elif defined(ARCH_SIM)
239+
/* Simulator: no linker script, use bootloader partition region */
241240
#if defined(WOLFBOOT_PARTITION_BOOT_ADDRESS) && defined(ARCH_FLASH_OFFSET)
242241
#define SELF_HASH_ADDR ((uintptr_t)ARCH_FLASH_OFFSET)
243242
#define SELF_HASH_SZ ((uint32_t)((uintptr_t)WOLFBOOT_PARTITION_BOOT_ADDRESS - \
244243
(uintptr_t)ARCH_FLASH_OFFSET))
245244
#endif
245+
#else
246+
/* Default: measure wolfBoot's own code using linker script symbols */
247+
extern unsigned int _start_text;
248+
extern unsigned int _stored_data;
249+
#define SELF_HASH_ADDR ((uintptr_t)&_start_text)
250+
#define SELF_HASH_SZ ((uint32_t)((uintptr_t)&_stored_data - \
251+
(uintptr_t)&_start_text))
246252
#endif
247253

248254
#ifdef SELF_HASH_ADDR

0 commit comments

Comments
 (0)