You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
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>
7 years ago
..
autoconf treewide: clean up download hashes 8 years ago
automake automake: Update to version 1.15.1 7 years ago
b43-tools b43-tools: fix tarball hash 8 years ago
bc treewide: clean up download hashes 8 years ago
bison tools: patch various gnu tools for macOS 10.13 7 years ago
ccache ccache: update to 3.3.4 7 years ago
cmake cmake: fix build error with Xcode 9 on macOS 12 7 years ago
coreutils tools: patch various gnu tools for macOS 10.13 7 years ago
dosfstools tools/dosfstools: Update to 4.1 7 years ago
e2fsprogs tools/e2fsprogs: Update to 1.43.6 7 years ago
elftosb treewide: clean up download hashes 8 years ago
expat tools/expat: Update to 2.2.4 7 years ago
findutils tools/findutils: include sysmacros.h explicitly 7 years ago
firmware-utils tools/firmware-utils: mktplinkfw* fix rootfs offset 7 years ago
flex tools: flex: fix segfault with glibc 2.26+ 7 years ago
flock tools: flock: add NFSv4 compatibility 8 years ago
genext2fs treewide: clean up download hashes 8 years ago
gengetopt treewide: clean up download hashes 8 years ago
gmp tools: gmp: Update to 6.1.2 8 years ago
include tools: host/include/getline.h: Remove 7 years ago
isl tools/isl: update to 0.18 7 years ago
kernel2minor tools: update kernel2minor to 0.24 version 7 years ago
libelf treewide: clean up download hashes 8 years ago
libressl tools/libressl: update to 2.5.4 7 years ago
libtool treewide: clean up download hashes 8 years ago
lzma treewide: clean up download hashes 8 years ago
lzma-old treewide: clean up download hashes 8 years ago
m4 tools: patch various gnu tools for macOS 10.13 7 years ago
make-ext4fs treewide: clean up and unify PKG_VERSION for git based downloads 8 years ago
missing-macros tools: remove a bunch of unused automake macros 9 years ago
mkimage tools/mkimage: fix musl build 7 years ago
mklibs treewide: clean up download hashes 8 years ago
mm-macros tools/mm-macros: Update to 0.9.11 7 years ago
mpc treewide: clean up download hashes 8 years ago
mpfr tools/mpfr: Update to 3.1.6 7 years ago
mtd-utils tools/mtd-utils: include sysmacros.h explicitly 7 years ago
mtools treewide: clean up download hashes 8 years ago
padjffs2 tools: padjffs2: add option to output padding data to stdout 8 years ago
patch tools: patch various gnu tools for macOS 10.13 7 years ago
patch-image tools: patch-image: fix file descriptor leak. 7 years ago
patchelf treewide: clean up download hashes 8 years ago
pkg-config tools/pkg-config: Update to 0.29.2 7 years ago
qemu qemu: rename internal crypto/aes symbols 7 years ago
quilt treewide: clean up download hashes 8 years ago
scons treewide: clean up download hashes 8 years ago
sdimage treewide: clean up and unify PKG_VERSION for git based downloads 8 years ago
sed tools/sed: Update to 4.4 7 years ago
sparse tools/sparse: Update to snapshot 2017-03-31 7 years ago
squashfs tools/squashfs: include sysmacros.h explicitly 7 years ago
squashfs4 tools/squashfs4: include sysmacros.h explicitly 7 years ago
sstrip tools: remove static linking support 9 years ago
tar tools: patch various gnu tools for macOS 10.13 7 years ago
upslug2 treewide: clean up download hashes 8 years ago
wrt350nv2-builder tools: remove static linking support 9 years ago
xz xz: Update to 5.2.3 8 years ago
Makefile tools/upx: Remove from repo 7 years ago