]> www.infradead.org Git - users/hch/misc.git/commitdiff
sh: Align .bss section padding to 8-byte boundary
authorArtur Rojek <contact@artur-rojek.eu>
Sun, 16 Feb 2025 17:55:44 +0000 (18:55 +0100)
committerJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Sat, 5 Apr 2025 17:46:34 +0000 (19:46 +0200)
J2-based devices expect to find a device tree blob at the end of the
.bss section. As of a77725a9a3c5 ("scripts/dtc: Update to upstream
version v1.6.1-19-g0a3a9d3449c8"), libfdt enforces 8-byte alignment
for the DTB, causing J2 devices to fail early in sh_fdt_init().

As the J2 loader firmware calculates the DTB location based on the kernel
image .bss section size rather than the __bss_stop symbol offset, the
required alignment can't be enforced with BSS_SECTION(0, PAGE_SIZE, 8).

To fix this, inline a modified version of the above macro which grows
.bss by the required size. While this change affects all existing SH
boards, it should be benign on platforms which don't need this alignment.

Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Tested-by: Rob Landley <rob@landley.net>
Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
arch/sh/kernel/vmlinux.lds.S

index 9644fe187a3f4e13e3cf4e84d2e3866a1d4f754e..008c30289eaa6d27bd7452e011eec1041258b901 100644 (file)
@@ -71,7 +71,20 @@ SECTIONS
 
        . = ALIGN(PAGE_SIZE);
        __init_end = .;
-       BSS_SECTION(0, PAGE_SIZE, 4)
+       __bss_start = .;
+       SBSS(0)
+       . = ALIGN(PAGE_SIZE);
+       .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
+               BSS_FIRST_SECTIONS
+               . = ALIGN(PAGE_SIZE);
+               *(.bss..page_aligned)
+               . = ALIGN(PAGE_SIZE);
+               *(.dynbss)
+               *(BSS_MAIN)
+               *(COMMON)
+               . = ALIGN(8);
+       }
+       __bss_stop = .;
        _end = . ;
 
        STABS_DEBUG