zImage
bootpimage.jpg from mkl Note
kernel-init-4-728.jpg?cb=1318556304 from https://hackmd.io/s/BJroQrL-g
  • [path to kernel]/arch/arm/boot/compressed/Makefile
LDFLAGS_vmlinux := --defsym zreladdr=$(ZRELADDR)
  • [path to kernel]/arch/arm/boot/compressed/head.S
        .word    zreladdr        @ r4
  • [path to kernel]/arch/arm/boot/compressed/misc.c

Check to see if we will overwrite ourselves.
r4 = final kernel address
r9 = size of decompressed image
r10 = end of this image, including bss/stack/malloc space if non XIP
We basically want:
(1). r4 - 16k page directory >= r10
vmlinux的起始地址大于zImage运行时所需的最大地址(r4 - 16k)
(2). r4 + image length <= address of wont_overwrite
zImage的起始地址大于vmlinux的目标起始地址加上vmlinux大小(r9)
(3). Relocate ourselves past the end of the decompressed kernel.
vmlinux的目标位置刚好和zImage的当前位置重合,所以解决方案就是先将zImage解压到zImage的上面,再将其重定位或者说搬移到目标位置。

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License