[U-Boot] [PATCH 0/3] 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(-)

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.
Signed-off-by: Alexander Graf agraf@suse.de --- 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(-)
diff --git a/arch/x86/cpu/u-boot-64.lds b/arch/x86/cpu/u-boot-64.lds index 862aa2d35e..98c7f8e9c5 100644 --- a/arch/x86/cpu/u-boot-64.lds +++ b/arch/x86/cpu/u-boot-64.lds @@ -95,7 +95,7 @@ SECTIONS
.bss __rel_dyn_start (OVERLAY) : { __bss_start = .; - *(.bss) + *(.bss*) *(COM*) . = ALIGN(4); __bss_end = .; diff --git a/arch/x86/cpu/u-boot.lds b/arch/x86/cpu/u-boot.lds index a1cc19ce4c..a283c290ee 100644 --- a/arch/x86/cpu/u-boot.lds +++ b/arch/x86/cpu/u-boot.lds @@ -94,7 +94,7 @@ SECTIONS
.bss __rel_dyn_start (OVERLAY) : { __bss_start = .; - *(.bss) + *(.bss*) *(COM*) . = ALIGN(4); __bss_end = .; diff --git a/arch/x86/lib/elf_ia32_efi.lds b/arch/x86/lib/elf_ia32_efi.lds index 983fabbc4d..aad61e7f81 100644 --- a/arch/x86/lib/elf_ia32_efi.lds +++ b/arch/x86/lib/elf_ia32_efi.lds @@ -46,7 +46,7 @@ SECTIONS *(.sbss) *(.scommon) *(.dynbss) - *(.bss) + *(.bss*) *(COMMON)
/* U-Boot lists and device tree */ diff --git a/arch/x86/lib/elf_x86_64_efi.lds b/arch/x86/lib/elf_x86_64_efi.lds index 7cad70a2e4..b436429b33 100644 --- a/arch/x86/lib/elf_x86_64_efi.lds +++ b/arch/x86/lib/elf_x86_64_efi.lds @@ -44,7 +44,7 @@ SECTIONS *(.sbss) *(.scommon) *(.dynbss) - *(.bss) + *(.bss*) *(COMMON) *(.rel.local)

On Mon, Aug 20, 2018 at 8:32 PM, Alexander Graf agraf@suse.de wrote:
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.
Signed-off-by: Alexander Graf agraf@suse.de
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(-)
Reviewed-by: Bin Meng bmeng.cn@gmail.com Tested-by: Bin Meng bmeng.cn@gmail.com

We 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.
Signed-off-by: Alexander Graf agraf@suse.de --- arch/x86/config.mk | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/arch/x86/config.mk b/arch/x86/config.mk index 586e11a0dd..5b04febd68 100644 --- a/arch/x86/config.mk +++ b/arch/x86/config.mk @@ -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)

On Mon, Aug 20, 2018 at 8:32 PM, Alexander Graf agraf@suse.de wrote:
We 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.
Signed-off-by: Alexander Graf agraf@suse.de
arch/x86/config.mk | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
Reviewed-by: Bin Meng bmeng.cn@gmail.com Tested-by: Bin Meng bmeng.cn@gmail.com

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.
Signed-off-by: Alexander Graf agraf@suse.de --- arch/riscv/cpu/ax25/u-boot.lds | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/riscv/cpu/ax25/u-boot.lds b/arch/riscv/cpu/ax25/u-boot.lds index 3cc89746b1..c50b9642f1 100644 --- a/arch/riscv/cpu/ax25/u-boot.lds +++ b/arch/riscv/cpu/ax25/u-boot.lds @@ -82,7 +82,7 @@ SECTIONS
.bss : { __bss_start = .; - *(.bss) + *(.bss*) . = ALIGN(4); __bss_end = .; }
participants (2)
-
Alexander Graf
-
Bin Meng