arc-c/files/initrd/opt/arc/bzImage-to-vmlinux.sh
AuxXxilium b1694ade0c tree: rework all patch apply
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
2023-11-03 21:24:47 +01:00

16 lines
511 B
Bash
Executable File

#!/usr/bin/env bash
read_u8() {
dd if=$1 bs=1 skip=$(($2)) count=1 2>/dev/null | od -An -tu1 | grep -Eo '[0-9]+'
}
read_u32() {
dd if=$1 bs=1 skip=$(($2)) count=4 2>/dev/null | od -An -tu4 | grep -Eo '[0-9]+'
}
set -x
setup_size=$(read_u8 $1 0x1f1)
payload_offset=$(read_u32 $1 0x248)
payload_length=$(read_u32 $1 0x24c)
inner_pos=$((($setup_size + 1) * 512))
tail -c+$(($inner_pos + 1)) $1 | tail -c+$(($payload_offset + 1)) | head -c $(($payload_length)) | head -c $(($payload_length - 4)) | unlzma >$2