Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: 8067/1: zImage: ensure header in LE format for BE8 kernels

All known BE8-capable systems have LE bootloaders, so we need to ensure
that the magic number and image start/end values are in little endian
format.

[ben.dooks@codethink.co.uk: from nico's original email on this subject]
[taras.kondratiuk@linaro.org: removed lds.S->lds rule, added target to extra-y]

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Nicolas Pitre and committed by
Russell King
33656d56 5c65c360

+21 -5
+1
arch/arm/boot/compressed/.gitignore
··· 10 10 piggy.lz4 11 11 vmlinux 12 12 vmlinux.lds 13 + vmlinux.lds.S 13 14 14 15 # borrowed libfdt files 15 16 fdt.c
+2 -2
arch/arm/boot/compressed/Makefile
··· 114 114 # Make sure files are removed during clean 115 115 extra-y += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern piggy.lz4 \ 116 116 lib1funcs.S ashldi3.S bswapsdi2.S $(libfdt) $(libfdt_hdrs) \ 117 - hyp-stub.S 117 + hyp-stub.S vmlinux.lds.S 118 118 119 119 ifeq ($(CONFIG_FUNCTION_TRACER),y) 120 120 ORIG_CFLAGS := $(KBUILD_CFLAGS) ··· 199 199 $(obj)/font.c: $(FONTC) 200 200 $(call cmd,shipped) 201 201 202 - $(obj)/vmlinux.lds: $(obj)/vmlinux.lds.in arch/arm/boot/Makefile $(KCONFIG_CONFIG) 202 + $(obj)/vmlinux.lds.S: $(obj)/vmlinux.lds.in arch/arm/boot/Makefile $(KCONFIG_CONFIG) 203 203 @sed "$(SEDFLAGS)" < $< > $@ 204 204 205 205 $(obj)/hyp-stub.S: $(srctree)/arch/$(SRCARCH)/kernel/hyp-stub.S
+4 -3
arch/arm/boot/compressed/head.S
··· 125 125 THUMB( adr r12, BSYM(1f) ) 126 126 THUMB( bx r12 ) 127 127 128 - .word 0x016f2818 @ Magic numbers to help the loader 129 - .word start @ absolute load/run zImage address 130 - .word _edata @ zImage end address 128 + .word _magic_sig @ Magic numbers to help the loader 129 + .word _magic_start @ absolute load/run zImage address 130 + .word _magic_end @ zImage end address 131 + 131 132 THUMB( .thumb ) 132 133 1: 133 134 ARM_BE8( setend be ) @ go BE8 if compiled for BE8
+14
arch/arm/boot/compressed/vmlinux.lds.in
··· 7 7 * it under the terms of the GNU General Public License version 2 as 8 8 * published by the Free Software Foundation. 9 9 */ 10 + 11 + #ifdef CONFIG_CPU_ENDIAN_BE8 12 + #define ZIMAGE_MAGIC(x) ( (((x) >> 24) & 0x000000ff) | \ 13 + (((x) >> 8) & 0x0000ff00) | \ 14 + (((x) << 8) & 0x00ff0000) | \ 15 + (((x) << 24) & 0xff000000) ) 16 + #else 17 + #define ZIMAGE_MAGIC(x) (x) 18 + #endif 19 + 10 20 OUTPUT_ARCH(arm) 11 21 ENTRY(_start) 12 22 SECTIONS ··· 66 56 /* (without a dummy byte, ld just ignores the empty section) */ 67 57 .pad : { BYTE(0); . = ALIGN(8); } 68 58 _edata = .; 59 + 60 + _magic_sig = ZIMAGE_MAGIC(0x016f2818); 61 + _magic_start = ZIMAGE_MAGIC(_start); 62 + _magic_end = ZIMAGE_MAGIC(_edata); 69 63 70 64 . = BSS_START; 71 65 __bss_start = .;