ARM: 6503/1: Thumb-2: Restore sensible zImage header layout for CONFIG_THUMB2_KERNEL

The code which makes up the zImage header intends to leave a
32-byte gap followed by a branch to the real entry point, a magic
number, and a word containing the absolute entry point address.

This gets messed up with with CONFIG_THUMB2_KERNEL, because the
size of the initial padding NOPs changes.

Instead, the header can be made fully compatible by restoring it to
ARM.

In the Thumb-2 case, we can replace the initial NOPs with a
sequence which switches to Thumb and jumps to the real entry point.

As a consequence, the zImage entry point is now always ARM, so no
special magic is needed any more for the uImage rules in the
Thumb-2 case.

Signed-off-by: Dave Martin <dave.martin@linaro.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by Dave Martin and committed by Russell King 26e5ca93 bfa64c4a

+6 -6
-5
arch/arm/boot/Makefile
··· 70 70 $(obj)/uImage: LOADADDR=$(ZRELADDR) 71 71 endif 72 72 73 - ifeq ($(CONFIG_THUMB2_KERNEL),y) 74 - # Set bit 0 to 1 so that "mov pc, rx" switches to Thumb-2 mode 75 - $(obj)/uImage: STARTADDR=$(shell echo $(LOADADDR) | sed -e "s/.$$/1/") 76 - else 77 73 $(obj)/uImage: STARTADDR=$(LOADADDR) 78 - endif 79 74 80 75 $(obj)/uImage: $(obj)/zImage FORCE 81 76 $(call if_changed,uimage)
+6 -1
arch/arm/boot/compressed/head.S
··· 125 125 * sort out different calling conventions 126 126 */ 127 127 .align 128 + .arm @ Always enter in ARM state 128 129 start: 129 130 .type start,#function 130 - .rept 8 131 + THUMB( adr r12, BSYM(1f) ) 132 + THUMB( bx r12 ) 133 + THUMB( .rept 6 ) 134 + ARM( .rept 8 ) 131 135 mov r0, r0 132 136 .endr 133 137 ··· 139 135 .word 0x016f2818 @ Magic numbers to help the loader 140 136 .word start @ absolute load/run zImage address 141 137 .word _edata @ zImage end address 138 + THUMB( .thumb ) 142 139 1: mov r7, r1 @ save architecture ID 143 140 mov r8, r2 @ save atags pointer 144 141