Openwrt/tools
Thibaut VARÈNE 050fb3b55c tools/firmware-utils: mktplinkfw* fix rootfs offset
With '-a' specified on the command line, the current code:
- computes an aligned _kernel length_ instead of an aligned _rootfs
  offset_.
- does not update the rootfs offset after computing the new kernel
  length, and instead retains the layout default.

When the kernel length exceeds the available space left with this
fixed offset, the resulting image header contains invalid data, with
the recorded rootfs offset overlapping the kernel area.

This patch ensures that rootfs offset is correctly computed and
reflected in the final image.

Furthermore, the build_fw() function special cases the rootfs_align
option because of the above invalid logic. This is also fixed and
the computed (or command-line provided, or layout-provided) rootfs_ofs
value is used in all cases.

There seems to be no valid reason to extend the kernel length beyond
the actual length of the kernel itself (OFW images don't do it) so this
part of the existing behavior is dropped.

Example image before the patch:
Kernel data offset     : 0x00000200 /      512 bytes
Kernel data length     : 0x00158438 /  1410104 bytes
Kernel load address    : 0x00000080
Kernel entry point     : 0x00000080
Rootfs data offset     : 0x00140000 /  1310720 bytes
Rootfs data length     : 0x001e4f7e /  1986430 bytes

Example image after the patch:
Kernel data offset     : 0x00000200 /      512 bytes
Kernel data length     : 0x001583fe /  1410046 bytes
Kernel load address    : 0x00000080
Kernel entry point     : 0x00000080
Rootfs data offset     : 0x00158600 /  1410560 bytes
Rootfs data length     : 0x001e4e22 /  1986082 bytes

Tested-by: Mathias Kresin <dev@kresin.me>
Tested-by: Stefan Lippers-Hollmann <s.l-h@gmx.de>
Tested-by: Daniel Engberg <daniel.engberg.lists@pyret.net>
Tested-by: Henryk Heisig <hyniu@o2.pl>
Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
2017-11-08 23:18:22 +01:00
..
autoconf
automake
b43-tools
bc
bison tools: patch various gnu tools for macOS 10.13 2017-08-23 18:56:33 +02:00
ccache
cmake cmake: fix build error with Xcode 9 on macOS 12 2017-10-05 21:14:44 +02:00
coreutils tools: patch various gnu tools for macOS 10.13 2017-08-23 18:56:33 +02:00
dosfstools
e2fsprogs tools/e2fsprogs: Update to 1.43.6 2017-09-16 22:22:44 +02:00
elftosb
expat tools/expat: Update to 2.2.4 2017-09-16 22:22:44 +02:00
findutils tools/findutils: include sysmacros.h explicitly 2017-10-27 11:19:38 +02:00
firmware-utils tools/firmware-utils: mktplinkfw* fix rootfs offset 2017-11-08 23:18:22 +01:00
flex tools: flex: fix segfault with glibc 2.26+ 2017-09-24 16:28:28 +02:00
flock
genext2fs
gengetopt
gmp
include
isl
kernel2minor
libelf
libressl
libtool
lzma
lzma-old
m4 tools: patch various gnu tools for macOS 10.13 2017-08-23 18:56:33 +02:00
make-ext4fs
missing-macros
mkimage tools/mkimage: fix musl build 2017-08-23 15:12:15 +02:00
mklibs
mm-macros tools/mm-macros: Update to 0.9.11 2017-09-30 22:43:59 +02:00
mpc
mpfr tools/mpfr: Update to 3.1.6 2017-09-30 22:43:38 +02:00
mtd-utils tools/mtd-utils: include sysmacros.h explicitly 2017-10-27 11:19:38 +02:00
mtools
padjffs2
patch tools: patch various gnu tools for macOS 10.13 2017-08-23 18:56:33 +02:00
patch-image
patchelf
pkg-config tools/pkg-config: Update to 0.29.2 2017-08-09 23:20:56 +02:00
qemu
quilt
scons
sdimage
sed
sparse
squashfs tools/squashfs: include sysmacros.h explicitly 2017-10-27 11:19:38 +02:00
squashfs4 tools/squashfs4: include sysmacros.h explicitly 2017-10-27 11:19:38 +02:00
sstrip
tar tools: patch various gnu tools for macOS 10.13 2017-08-23 18:56:33 +02:00
upslug2
wrt350nv2-builder
xz
Makefile