1 #!/bin/bash 2 # This script processes symbols output by Gallium using glibc to human-readable function names 3 4 lastbin= 5 i=-1 6 dir="$(mktemp -d)" 7 input="$1" 8 9 # Gather all unique addresses for each binary 10 sed -nre 's|([^ ]*/[^ ]*)\(\+0x([^)]*).*|\1 \2|p' "$input"|sort|uniq|while read bin addr; do 11 if test "$lastbin" != "$bin"; then 12 ((++i)) 13 lastbin="$bin" 14 echo "$bin" > "$dir/$i.addrs.bin" 15 fi 16 echo "$addr" >> "$dir/$i.addrs" 17 done 18 19 # Construct a sed script to convert hex address to human readable form, and apply it 20 for i in "$dir"/*.addrs; do 21 bin="$(<"$i.bin")" 22 addr2line -p -e "$bin" -a -f < "$i"|sed -nre 's@^0x0*([^:]*): ([^?]*)$@s|'"$bin"'(+0x\1)|\2|g@gp' 23 rm -f "$i" "$i.bin" 24 done|sed -f - "$input" 25 26 rmdir "$dir" 27