Thomas Bogendoerfer <tsbogend@xxxxxxxxxxxxxxxx> writes: > I see > > diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S > index c1c345be04ff..4b4e39b7c79b 100644 > --- a/arch/mips/kernel/vmlinux.lds.S > +++ b/arch/mips/kernel/vmlinux.lds.S > @@ -145,6 +145,7 @@ SECTIONS > } > > #ifdef CONFIG_MIPS_ELF_APPENDED_DTB > + STRUCT_ALIGN(); > .appended_dtb : AT(ADDR(.appended_dtb) - LOAD_OFFSET) { > *(.appended_dtb) > KEEP(*(.appended_dtb)) > @@ -172,6 +173,7 @@ SECTIONS > #endif > > #ifdef CONFIG_MIPS_RAW_APPENDED_DTB > + STRUCT_ALIGN(); > __appended_dtb = .; > /* leave space for appended DTB */ > . += 0x100000; > > in that patch, and IMHO this does align the appended_dtb. What do I miss ? I'll not pretend I know anything about this subject, so feel free to adjust as necessary. The problem with that patch is that it doesn't pad the image to the aligment. So you can't do cat my.dtb >> arch/mips/boot/vmlinux.bin anymore. This used to work before commit 79edff12060f. This is an image build with that patch and an initramfs: bjorn@canardo:/usr/local/src/build-tmp/linux$ ls -l arch/mips/boot/vmlinux.bin -rwxr-xr-x 1 bjorn src 15724964 Mar 8 14:21 arch/mips/boot/vmlinux.bin So that's aligned to 4 bytes, because it's terminated by the 32bit length of the initramfs: 15724964/8 1965620.50000000000000000000 Building with the attached patch results in: bjorn@canardo:/usr/local/src/build-tmp/linux$ ls -l arch/mips/boot/vmlinux.bin -rwxr-xr-x 1 bjorn src 15724992 Mar 8 14:29 arch/mips/boot/vmlinux.bin Which is aligned to the 32 bytes expected after STRUCT_ALIGN(): 15724992/8 1965624.00000000000000000000 The tail of the image shows the cpio trailer and cpio length (0x0061f400) followed by enough padding to align an appended DTB to 32 bytes: bjorn@canardo:/usr/local/src/build-tmp/linux$ ls -l arch/mips/boot/vmlinux.bin -rwxr-xr-x 1 bjorn src 15724992 Mar 8 14:29 arch/mips/boot/vmlinux.bin bjorn@canardo:/usr/local/src/build-tmp/linux$ hexdump -C arch/mips/boot/vmlinux.bin|tail 00eff090 30 30 30 30 30 30 30 30 30 31 30 30 30 30 30 30 |0000000001000000| 00eff0a0 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 |0000000000000000| * 00eff0d0 30 42 30 30 30 30 30 30 30 30 54 52 41 49 4c 45 |0B00000000TRAILE| 00eff0e0 52 21 21 21 00 00 00 00 00 00 00 00 00 00 00 00 |R!!!............| 00eff0f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00eff1a0 00 61 f4 00 00 00 00 00 00 00 00 00 00 00 00 00 |.a..............| 00eff1b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00eff1c0 Yes, you can always pad the image yourself if you know about this alignment requirement. But it gets more complicated. And it breaks my home grown hackish build script. I know I'm not the only one... Bjørn
>From c1bd611ae62db46db12d86196cade2613a291400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= <bjorn@xxxxxxx> Date: Mon, 8 Mar 2021 14:24:17 +0100 Subject: [PATCH] MIPS: vmlinux.lds.S: fill vmlinux.bin to DTB alignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Padding the binary to the required alignment for raw appended DTBs so that it is possible to append one without detailed knowledge of this requirement. Signed-off-by: Bjørn Mork <bjorn@xxxxxxx> --- arch/mips/kernel/vmlinux.lds.S | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S index 4b4e39b7c79b..1f98947fe715 100644 --- a/arch/mips/kernel/vmlinux.lds.S +++ b/arch/mips/kernel/vmlinux.lds.S @@ -173,7 +173,11 @@ SECTIONS #endif #ifdef CONFIG_MIPS_RAW_APPENDED_DTB - STRUCT_ALIGN(); + .fill : { + FILL(0); + BYTE(0); + STRUCT_ALIGN(); + } __appended_dtb = .; /* leave space for appended DTB */ . += 0x100000; -- 2.20.1