x86_fsp: enable linker sections garbage collection

-ffunction-sections -fdata-sections compiles every function/data in its own
section, --gc-sections will remove the one that are unused.

Before:
$ ./tools/x86_fsp/print_flash_map.py
Name:                    Address:                    Size:
.stage2              0xffa00000           0x52cac
.policy              0xffa52cac           0x204
.config              0xffa52eb0           0x220
.ucode_update0       0xffd90000           0x1b000
.fit_table           0xffe00000           0x63000
.km                  0xffe80000           0x1000
.bpm                 0xffe90000           0x1000
.fsp_s               0xffea0000           0x5a200
.bootloader          0xfff00000           0x4f600
.iplt                0xfff4f600           0x0
.fsp_t               0xfff59000           0x7000
.fsp_m               0xfff60000           0x9f000
.jmpto32             0xfffffe00           0x158
.fit_table_tr        0xffffffc0           0x8
.reset_vector        0xffffffec           0x14
total sum: 0x222a44 (2186 KB)

After:
$ ./tools/x86_fsp/print_flash_map.py
Name:                    Address:                    Size:
.stage2              0xffa00000           0x2b24c
.policy              0xffa2b24c           0x204
.config              0xffa2b450           0x220
.ucode_update0       0xffd90000           0x1b000
.fit_table           0xffe00000           0x63000
.km                  0xffe80000           0x1000
.bpm                 0xffe90000           0x1000
.fsp_s               0xffea0000           0x5a200
.bootloader          0xfff00000           0x20900
.iplt                0xfff20900           0x0
.fsp_t               0xfff59000           0x7000
.fsp_m               0xfff60000           0x9f000
.jmpto32             0xfffffe00           0x158
.fit_table_tr        0xffffffc0           0x8
.reset_vector        0xffffffec           0x14
total sum: 0x1cc2e4 (1840 KB)
pull/443/head
Marco Oliverio 2024-02-08 16:06:15 +01:00
parent 94733b564c
commit d0e6a7e990
2 changed files with 4 additions and 2 deletions

View File

@ -649,6 +649,7 @@ endif
ifeq ($(filter $(TARGET),x86_fsp_qemu kontron_vx3060_s2),$(TARGET))
FSP=1
CFLAGS+=-DWOLFBOOT_FSP=1
CFLAGS+=-ffunction-sections -fdata-sections
ifeq ($(TARGET), kontron_vx3060_s2)
FSP_TGL=1
CFLAGS+=-DWOLFBOOT_TGL=1
@ -679,7 +680,7 @@ ifeq ("${FSP}", "1")
--defsym wb_start_bss=0x`nm ../wolfboot.elf | grep -w _start_bss | awk '{print $$1}'` \
--defsym wb_end_bss=0x`nm ../wolfboot.elf | grep -w _end_bss | awk '{print $$1}'` \
--defsym _stage2_params=0x`nm ../wolfboot.elf | grep -w _stage2_params | awk '{print $$1}'`
LDFLAGS += --no-gc-sections --print-gc-sections -T $(LSCRIPT) -m elf_i386 -Map=loader_stage1.map
LDFLAGS += --gc-sections --print-gc-sections --entry=reset_vector -T $(LSCRIPT) -m elf_i386 -Map=loader_stage1.map
OBJS += src/boot_x86_fsp.o
OBJS += src/boot_x86_fsp_start.o
OBJS += src/fsp_m.o
@ -720,7 +721,7 @@ ifeq ("${FSP}", "1")
else
LSCRIPT_IN = hal/$(TARGET).ld.in
endif
LDFLAGS = --no-gc-sections --print-gc-sections -T $(LSCRIPT) -Map=wolfboot.map
LDFLAGS = --gc-sections --print-gc-sections --entry=main -T $(LSCRIPT) -Map=wolfboot.map
CFLAGS += -fno-stack-protector -fno-PIC -fno-pie -mno-mmx -mno-sse -Os -DDEBUG_UART
OBJS += hal/x86_fsp_tgl.o
OBJS += hal/x86_uart.o

View File

@ -151,6 +151,7 @@ TempRamInitSuccess:
[section .reset_vector]
BITS 16
ALIGN 16
global reset_vector
reset_vector:
nop
nop