Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26e5ca93 authored by Dave Martin's avatar Dave Martin Committed by Russell King
Browse files

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: default avatarDave Martin <dave.martin@linaro.org>
Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Acked-by: default avatarNicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent bfa64c4a
Loading
Loading
Loading
Loading
+0 −5
Original line number Original line Diff line number Diff line
@@ -70,12 +70,7 @@ else
$(obj)/uImage: LOADADDR=$(ZRELADDR)
$(obj)/uImage: LOADADDR=$(ZRELADDR)
endif
endif


ifeq ($(CONFIG_THUMB2_KERNEL),y)
# Set bit 0 to 1 so that "mov pc, rx" switches to Thumb-2 mode
$(obj)/uImage: STARTADDR=$(shell echo $(LOADADDR) | sed -e "s/.$$/1/")
else
$(obj)/uImage: STARTADDR=$(LOADADDR)
$(obj)/uImage: STARTADDR=$(LOADADDR)
endif


$(obj)/uImage:	$(obj)/zImage FORCE
$(obj)/uImage:	$(obj)/zImage FORCE
	$(call if_changed,uimage)
	$(call if_changed,uimage)
+6 −1
Original line number Original line Diff line number Diff line
@@ -125,9 +125,13 @@ wait: mrc p14, 0, pc, c0, c1, 0
 * sort out different calling conventions
 * sort out different calling conventions
 */
 */
		.align
		.align
		.arm				@ Always enter in ARM state
start:
start:
		.type	start,#function
		.type	start,#function
		.rept	8
 THUMB(		adr	r12, BSYM(1f)	)
 THUMB(		bx	r12		)
 THUMB(		.rept	6		)
 ARM(		.rept	8		)
		mov	r0, r0
		mov	r0, r0
		.endr
		.endr


@@ -135,6 +139,7 @@ start:
		.word	0x016f2818		@ Magic numbers to help the loader
		.word	0x016f2818		@ Magic numbers to help the loader
		.word	start			@ absolute load/run zImage address
		.word	start			@ absolute load/run zImage address
		.word	_edata			@ zImage end address
		.word	_edata			@ zImage end address
 THUMB(		.thumb			)
1:		mov	r7, r1			@ save architecture ID
1:		mov	r7, r1			@ save architecture ID
		mov	r8, r2			@ save atags pointer
		mov	r8, r2			@ save atags pointer