Quick status update:
No luck yet getting the CHDK shell to boot. Don't know where exactly goes wrong, might be a mistake in the code so far or I haven't done something yet (the number of patched functions from r47 reference port differs from r45, need to start trying some variations between the two).
I need to look at something different for a while, so I decided to resolve the stubs.S and stubs_mini.S files in the mean time (I noticed that the CHDK improved auto detection, so there is not as much left to find by hand).
And for that I wrote a bash script that parses trough gcc disassembly and find the assembly functions, described by the input parameters:
#!/bin/bash
clear
echo "File : $1"
echo "Start : $2"
echo "End : $3"
echo "Lines : $4"
echo "Pattern: $5"
# acquire
DATA=`sed -n '/\t'$2'/,/\t'$3'/p' $1`
RESULT=""
# output
echo
echo "--------------------------------- RESULT ----------------------------------"
echo
# process
while read -r line; do
# start pattern found
if echo "$line" | grep -q -w -i "$2"; then
lineCounter=0
block=""
fi
# adding lines
block="$block\n$line"
((lineCounter++))
# end pattern found
if echo "$line" | grep -q -w -i "$3"; then
# line limiting
if [[ "$4" -eq 0 ]]; then
block="$block\n"
else
if [[ "$lineCounter" -le "$4" ]]; then
block="$block\n"
else
block=""
fi
fi
# sub pattern matching
for i in $(echo $5 | tr "," "\n"); do
if echo -e "$block" | grep -q -w -i "$i"; then
continue
else
block=""
fi
done
#RESULT="$RESULT$block"
# output
if [[ "$block" != "" ]]; then
echo -e "$block"
fi
fi
done <<< "$DATA"
# output
echo
echo "---------------------------------- DONE -----------------------------------"
echo
Usage: sh patternFinder.sh <filename> <start_element> <end_element> <max_lines> <elements_array>
Example: sh patternFinder.sh A2200_1.00B.dis push b 0 "add,ldr"
So if anyone finds it useful for porting (or any kind of multi line pattern matching), or knows if scripts like this are collected somewhere here for any to find, let me know!