aboutsummaryrefslogtreecommitdiff
blob: 1c9cf87e3657c0045037fedff142a37820210e2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /bin/sh
# Script to check for duplicate function prologues in op.o
# Typically this indicates missing FORCE_RET();
# This script does not detect other errors that may be present.

# Usage: check_ops.sh [-m machine] [op.o]
#   machine and op.o are guessed if not specified.

if [ "x$1" = "x-m" ]; then
  machine=$2
  shift 2
else
  machine=`uname -m`
fi
if [ -z "$1" ]; then
  for f in `find . -name op.o`; do
    /bin/sh "$0" -m $machine $f
  done
  exit 0
fi

case $machine in
  i?86)
    ret='\tret'
    ;;
  x86_64)
    ret='\tretq'
    ;;
  arm)
    ret='\tldm.*pc'
    ;;
  ppc* | powerpc*)
    ret='\tblr'
    ;;
  mips*)
    ret='\tjr.*ra'
    ;;
  s390*)
    ret='\tbr.*'
    ;;
  *)
    echo "Unknown machine `uname -m`"
    ;;
esac
echo $1
# op_exit_tb causes false positives on some hosts.
${CROSS}objdump -dr $1  | \
  sed -e '/>:$\|'"$ret"'/!d' -e 's/.*<\(.*\)>:/~\1:/' -e 's/.*'"$ret"'.*/!/' | \
  sed -e ':1;N;s/\n//;t1' | sed -e 's/~/\n/g' | grep -v '^op_exit_tb' | \
  grep '^op_.*!!'