why kernel do eight times nop ?
Valdis.Kletnieks at vt.edu
Valdis.Kletnieks at vt.edu
Thu May 15 03:22:13 EDT 2014
On Thu, 15 May 2014 14:19:25 +0800, Chuck Huang said:
> hi All,
>
> is anyone can explain why kernel do eight times nop in
> arch/arm/boot/compressed/head.S ?
>
> 128 start:
> 129 .type start,#function
> 130 .rept 8
> 131 mov r0, r0
> 132 .endr
>
> what's the purpose of that ?
With 'git', you could figure that out yourself....
git blame arch/arm/boot/compressed/head.S says:
^1da177e4 (Linus Torvalds 2005-04-16 15:20:36 -0700 118) /*
^1da177e4 (Linus Torvalds 2005-04-16 15:20:36 -0700 119) * sort out different calling conventions
^1da177e4 (Linus Torvalds 2005-04-16 15:20:36 -0700 120) */
^1da177e4 (Linus Torvalds 2005-04-16 15:20:36 -0700 121) .align
26e5ca93d (Dave Martin 2010-11-29 19:43:27 +0100 122) .arm @ Always enter in ARM state
^1da177e4 (Linus Torvalds 2005-04-16 15:20:36 -0700 123) start:
^1da177e4 (Linus Torvalds 2005-04-16 15:20:36 -0700 124) .type start,#function
b11fe3888 (Nicolas Pitre 2011-02-12 22:25:27 +0100 125) .rept 7
^1da177e4 (Linus Torvalds 2005-04-16 15:20:36 -0700 126) mov r0, r0
^1da177e4 (Linus Torvalds 2005-04-16 15:20:36 -0700 127) .endr
b11fe3888 (Nicolas Pitre 2011-02-12 22:25:27 +0100 128) ARM( mov r0, r0 )
b11fe3888 (Nicolas Pitre 2011-02-12 22:25:27 +0100 129) ARM( b 1f )
b11fe3888 (Nicolas Pitre 2011-02-12 22:25:27 +0100 130) THUMB( adr r12, BSYM(1f) )
b11fe3888 (Nicolas Pitre 2011-02-12 22:25:27 +0100 131) THUMB( bx r12 )
^1da177e4 (Linus Torvalds 2005-04-16 15:20:36 -0700 132)
So the .rept 7 and related were added in commit b11fe38888 in Feb 2011.
git log b11fe3888
commit b11fe38883d1de76f2f847943e085a808f83f189
Author: Nicolas Pitre <nico at fluxnic.net>
Date: Sat Feb 12 22:25:27 2011 +0100
ARM: 6663/1: make Thumb2 kernel entry point more similar to the ARM one
Some installers would binary patch the kernel zImage to replace the
first few nops with custom instructions. This breaks the Thumb2 kernel
as the mode switch is right at the beginning. Let's move it towards the
end of the nop sequence instead.
Signed-off-by: Nicolas Pitre <nicolas.pitre at linaro.org>
Signed-off-by: Russell King <rmk+kernel at arm.linux.org.uk>
So there you have it - it's a nop sled for installers that would otherwise
trample the start of executable code.
If you're still confused, you'll have to ask Nicolas or Russell or an actual
ARM expert. :)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 848 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140515/82a262ad/attachment.bin
More information about the Kernelnewbies
mailing list