Skip to content

Commit 441200f

Browse files
douzzerrizlik
authored andcommitted
fix: support DEBUG=0 build
* build lib/wolfssl/wolfcrypt/src/logging.o unconditionally, * gate debug printing in do_tpm_selftest() appropriately, * initialize top_address in src/boot_x86_fsp.c:start() to fix -Wmaybe-uninitialized, * and add __attribute__((used)) to static src/x86/exceptions.c:common_exception_handler() and _timer_handler() implementations to accommodate asm-only calling; * fix parallel make: add dependency of stage1/loader_stage1.bin on wolfboot.elf. * add -ffreestanding -static flags to avoid gcc compiler optimize strings functions Co-authored-by: Daniel Pouzzner <[email protected]>
1 parent ca3e8dc commit 441200f

File tree

7 files changed

+20
-12
lines changed

7 files changed

+20
-12
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ BOOTLOADER_PARTITION_SIZE?=$$(( $(WOLFBOOT_PARTITION_BOOT_ADDRESS) - $(ARCH_FLAS
137137
all: $(MAIN_TARGET)
138138

139139
stage1: stage1/loader_stage1.bin
140+
stage1/loader_stage1.bin: wolfboot.elf
140141
stage1/loader_stage1.bin: FORCE
141142
@echo "\t[BIN] $@"
142143
$(Q)$(MAKE) -C $(dir $@) $(notdir $@)

arch.mk

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,10 @@ endif
671671
ifeq ($(filter $(TARGET),x86_fsp_qemu kontron_vx3060_s2),$(TARGET))
672672
FSP=1
673673
CFLAGS+=-DWOLFBOOT_FSP=1
674-
CFLAGS+=-ffunction-sections -fdata-sections
674+
CFLAGS+=-ffunction-sections -fdata-sections -ffreestanding -nostdlib -static
675+
# some std libc have headers that bring in extra symbols used in
676+
# FORTIFY_SOURCE realated checks. Use -U_FORTIFY_SOURCE to avoid that.
677+
CFLAGS+=-U_FORTIFY_SOURCE
675678
ifeq ($(TARGET), kontron_vx3060_s2)
676679
FSP_TGL=1
677680
CFLAGS+=-DWOLFBOOT_TGL=1
@@ -840,9 +843,7 @@ CFLAGS+=-DWOLFBOOT_ORIGIN=$(WOLFBOOT_ORIGIN)
840843
CFLAGS+=-DBOOTLOADER_PARTITION_SIZE=$(BOOTLOADER_PARTITION_SIZE)
841844

842845
## Debug
843-
ifeq ($(DEBUG),1)
844-
WOLFCRYPT_OBJS+=./lib/wolfssl/wolfcrypt/src/logging.o
845-
endif
846+
WOLFCRYPT_OBJS+=./lib/wolfssl/wolfcrypt/src/logging.o
846847

847848
# Debug UART
848849
ifeq ($(DEBUG_UART),1)

config/examples/kontron_vx3060_s2.config

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ TARGET=kontron_vx3060_s2
33
WOLFBOOT_SMALL_STACK=0
44
SIGN=ECC384
55
HASH=SHA256
6-
DEBUG=1
6+
DEBUG=0
77
SPMATH=1
88
ENCRYPTION=0
99
WOLFBOOT_NO_PARTITIONS=1
@@ -63,4 +63,5 @@ DISK_LOCK=0
6363
WOLFTPM=1
6464
WOLFBOOT_TPM_SEAL=1
6565
WOLFBOOT_TPM_SEAL_KEY_ID=1
66-
WOLFBOOT_UNIVERSAL_KEYSTORE=1
66+
WOLFBOOT_UNIVERSAL_KEYSTORE=1
67+
DEBUG_SYMBOLS=1

config/examples/x86_fsp_qemu_seal.config

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ TARGET=x86_fsp_qemu
33
WOLFBOOT_SMALL_STACK=0
44
SIGN=ECC384
55
HASH=SHA256
6-
DEBUG=1
6+
DEBUG=0
77
SPMATH=1
88
FORCE_32BIT=1
99
ENCRYPTION=0
@@ -45,4 +45,5 @@ MEASURED_PCR_A=0
4545
WOLFBOOT_TPM_SEAL=1
4646
WOLFBOOT_TPM_SEAL_KEY_ID=1
4747
DISK_LOCK=1
48-
WOLFBOOT_UNIVERSAL_KEYSTORE=1
48+
WOLFBOOT_UNIVERSAL_KEYSTORE=1
49+
DEBUG_SYMBOLS=1

include/user_settings.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@
4040
#define SIZEOF_LONG_LONG 8
4141

4242
#define CTYPE_USER /* don't let wolfCrypt types.h include ctype.h */
43+
#ifndef toupper
4344
extern int toupper(int c);
45+
#endif
46+
#ifndef tolower
4447
extern int tolower(int c);
48+
#endif
4549
#define XTOUPPER(c) toupper((c))
4650
#define XTOLOWER(c) tolower((c))
4751

src/boot_x86_fsp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ void start(uint32_t stack_base, uint32_t stack_top, uint64_t timestamp,
744744
uint8_t *fsp_m_base, done = 0;
745745
struct efi_hob *hobList, *it;
746746
memory_init_cb MemoryInit;
747-
uint64_t top_address;
747+
uint64_t top_address = MEMORY_4GB;
748748
uint32_t new_stack;
749749
uint32_t status;
750750
uint16_t type;
@@ -836,7 +836,7 @@ void start(uint32_t stack_base, uint32_t stack_top, uint64_t timestamp,
836836
hob_dump_memory_map(hobList);
837837
#endif /* DEBUG */
838838

839-
if (top_address > MEMORY_4GB) {
839+
if (top_address >= MEMORY_4GB) {
840840
panic();
841841
}
842842

src/x86/exceptions.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static struct idt_descriptor idt_descriptor;
7979
: ""(X)); \
8080
}
8181

82-
static void common_exception_handler(uint64_t vector_number)
82+
__attribute__((used)) static void common_exception_handler(uint64_t vector_number)
8383
{
8484
EXCEPTIONS_DEBUG_PRINTF("CPU exception: %d\r\n", (int)vector_number);
8585
}
@@ -133,7 +133,7 @@ int setup_interrupt_gate(int vnum, uintptr_t handler)
133133
ig->reserved = 0x0;
134134
}
135135

136-
static void _timer_handler()
136+
__attribute__((used)) static void _timer_handler()
137137
{
138138
EXCEPTIONS_DEBUG_PRINTF("In the timer handler\r\n");
139139
}

0 commit comments

Comments
 (0)