showasm 585 B

1234567891011121314151617181920
  1. #!/bin/sh
  2. # Copyright 2006 Rob Landley <rob@landley.net>
  3. # Dumb little utility function to print out the assembly dump of a single
  4. # function, or list the functions so dumpable in an executable. You'd think
  5. # there would be a way to get objdump to do this, but I can't find it.
  6. [ $# -lt 1 ] || [ $# -gt 2 ] && { echo "usage: showasm file function"; exit 1; }
  7. [ ! -f $1 ] && { echo "File $1 not found"; exit 1; }
  8. if [ $# -eq 1 ]
  9. then
  10. objdump -d $1 | sed -n -e 's/^[0-9a-fA-F]* <\(.*\)>:$/\1/p'
  11. exit 0
  12. fi
  13. objdump -d $1 | sed -n -e '/./{H;$!d}' -e "x;/^.[0-9a-fA-F]* <$2>:/p"