#!/bin/bash # copied from https://themkat.net/2022/12/19/gamecube_linux_sd_boot.html, which itself copied it from the now offline gc-linux wiki # edited slightly to make it more readable and convenient to use KSRC=${KSRC:-.} target=${1:-zImage} ofile=zImage [ -r ${KSRC}/arch/powerpc/boot/${target} ] || { echo "Can't find target image ${KSRC}/arch/powerpc/boot/${target}" exit 1 } cp ${KSRC}/arch/powerpc/boot/${target} ${ofile} CROSS=powerpc-linux-gnu- echo "+ building DOL" load=$(${CROSS}readelf -l "$ofile" | perl -lane'printf"%08x\n",hex($F[3])+0x80000000 if /LOAD/;') echo " LOAD: $load" entry=$(${CROSS}readelf -l "$ofile" | perl -lane'printf"%08x\n",hex($F[2])+0x80000000 if /Entry point/;') echo " EP : $entry" ${CROSS}objcopy -O binary -R .comment -R .shstrtab -R .symtab -R .strtab -R .gnu.attributes ${ofile} ${ofile}.bin doltool -c ${ofile}.bin $load $entry doltool -i ${ofile}.dol echo ""