1#!/usr/bin/env bash 2# This script processes symbols output by Gallium using glibc to human-readable function names 3 4lastbin= 5i=-1 6dir="$(mktemp -d)" 7input="$1" 8 9# Gather all unique addresses for each binary 10sed -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" 17done 18 19# Construct a sed script to convert hex address to human readable form, and apply it 20for 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" 24done|sed -f - "$input" 25 26rmdir "$dir" 27