efi_loader: Fix -fdata-section fallout with bss
cover efi_loader: Fix -fdata-section fallout with bss
While trying to fix efi_loader problems that could only be resolved by enabling individual function and data sections (commit 7e21fbca26d18 "efi_loader: Rename sections to allow for implicit data") some cases where .bss was included in the linker scripts slipped through.
This lead to random breakage when .bss contents were accessed, because the respective regions were not initialized properly.
With this patch set, all those should be resolved now.
Alex
Alexander Graf (3):
x86: Include bss subsections in linker script
x86: Enable -fdata-sections always
riscv: Include bss subsections in linker script
arch/riscv/cpu/ax25/u-boot.lds | 2 +- arch/x86/config.mk | 4 +--- arch/x86/cpu/u-boot-64.lds | 2 +- arch/x86/cpu/u-boot.lds | 2 +- arch/x86/lib/elf_ia32_efi.lds | 2 +- arch/x86/lib/elf_x86_64_efi.lds | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-)
Signature · 1 line
2.12.3
PATCH 1/3 x86: Include bss subsections in linker script
When we build with -fdata-sections we may end up with bss subsections. Our linker script explicitly lists only a single consecutive bss section though.
Adapt the statement to also include subsections.
This fixes booting efi-x86_app_defconfig.
--- arch/x86/cpu/u-boot-64.lds | 2 +- arch/x86/cpu/u-boot.lds | 2 +- arch/x86/lib/elf_ia32_efi.lds | 2 +- arch/x86/lib/elf_x86_64_efi.lds | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/cpu/u-boot-64.lds +1 -1
@@ -95,7 +95,7 @@ SECTIONS .bss __rel_dyn_start (OVERLAY) : { __bss_start = .; - *(.bss) + *(.bss*) *(COM*) . = ALIGN(4); __bss_end = .;
arch/x86/cpu/u-boot.lds +1 -1
@@ -94,7 +94,7 @@ SECTIONS .bss __rel_dyn_start (OVERLAY) : { __bss_start = .; - *(.bss) + *(.bss*) *(COM*) . = ALIGN(4); __bss_end = .;
arch/x86/lib/elf_ia32_efi.lds +1 -1
@@ -46,7 +46,7 @@ SECTIONS *(.sbss) *(.scommon) *(.dynbss) - *(.bss) + *(.bss*) *(COMMON) /* U-Boot lists and device tree */
arch/x86/lib/elf_x86_64_efi.lds +1 -1
@@ -44,7 +44,7 @@ SECTIONS *(.sbss) *(.scommon) *(.dynbss) - *(.bss) + *(.bss*) *(COMMON) *(.rel.local)
Signature · 1 line
2.12.3
PATCH 1/3 x86: Include bss subsections in linker script
Quoted 7 lines · Alexander Graf
When we build with -fdata-sections we may end up with bss subsections. Our linker script explicitly lists only a single consecutive bss section though.
Adapt the statement to also include subsections.
This fixes booting efi-x86_app_defconfig.
Quoted 8 lines
Signed-off-by Alexander Graf <[email protected]>--- arch/x86/cpu/u-boot-64.lds | 2 +- arch/x86/cpu/u-boot.lds | 2 +- arch/x86/lib/elf_ia32_efi.lds | 2 +- arch/x86/lib/elf_x86_64_efi.lds | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
PATCH 2/3 x86: Enable -fdata-sections always
In reply to Alexander GrafWe left -fdata-sections disabled for x86_64 before because we encountered random bugs that were at that time inexplicable.
Turns out this really was just side effects of missing .bss* statements in the linker scripts. With those fixed, we can enable data sections for all targets.
--- arch/x86/config.mk | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/x86/config.mk +1 -3
@@ -23,13 +23,11 @@ endif ifeq ($(IS_32BIT),y) PLATFORM_CPPFLAGS += -march=i386 -m32 -# TODO: These break on x86_64; need to debug further -PLATFORM_RELFLAGS += -fdata-sections else PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common -m64 endif -PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden +PLATFORM_RELFLAGS += -fdata-sections -ffunction-sections -fvisibility=hidden PLATFORM_LDFLAGS += -Bsymbolic -Bsymbolic-functions PLATFORM_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64)
Signature · 1 line
2.12.3
PATCH 2/3 x86: Enable -fdata-sections always
Quoted 12 lines · Alexander Graf
We left -fdata-sections disabled for
x86_64before because we encountered random bugs that were at that time inexplicable.Turns out this really was just side effects of missing .bss* statements in the linker scripts. With those fixed, we can enable data sections for all targets.
Signed-off-by Alexander Graf <[email protected]>--- arch/x86/config.mk | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
PATCH 3/3 riscv: Include bss subsections in linker script
In reply to Alexander GrafWhen we build with -fdata-sections we may end up with bss subsections. Our linker script explicitly lists only a single consecutive bss section though.
Adapt the statement to also include subsections.
--- arch/riscv/cpu/ax25/u-boot.lds | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/cpu/ax25/u-boot.lds +1 -1
@@ -82,7 +82,7 @@ SECTIONS .bss : { __bss_start = .; - *(.bss) + *(.bss*) . = ALIGN(4); __bss_end = .; }
Signature · 1 line
2.12.3