1# Copyright © 2016 IBM Corporation 2# 3# This program is free software; you can redistribute it and/or 4# modify it under the terms of the GNU General Public License 5# as published by the Free Software Foundation; either version 6# 2 of the License, or (at your option) any later version. 7# 8# This script checks the relocations of a vmlinux for "suspicious" 9# branches from unrelocated code (head_64.S code). 10 11# Turn this on if you want more debug output: 12# set -x 13 14# Have Kbuild supply the path to objdump so we handle cross compilation. 15objdump="$1" 16vmlinux="$2" 17 18#__end_interrupts should be located within the first 64K 19 20end_intr=0x$( 21$objdump -R "$vmlinux" -d --start-address=0xc000000000000000 \ 22 --stop-address=0xc000000000010000 | 23grep '\<__end_interrupts>:' | 24awk '{print $1}' 25) 26 27BRANCHES=$( 28$objdump -R "$vmlinux" -D --start-address=0xc000000000000000 \ 29 --stop-address=${end_intr} | 30grep -e "^c[0-9a-f]*:[[:space:]]*\([0-9a-f][0-9a-f][[:space:]]\)\{4\}[[:space:]]*b" | 31grep -v '\<__start_initialization_multiplatform>' | 32grep -v -e 'b.\?.\?ctr' | 33grep -v -e 'b.\?.\?lr' | 34sed -e 's/\bbt.\?[[:space:]]*[[:digit:]][[:digit:]]*,/beq/' \ 35 -e 's/\bbf.\?[[:space:]]*[[:digit:]][[:digit:]]*,/bne/' \ 36 -e 's/[[:space:]]0x/ /' \ 37 -e 's/://' | 38awk '{ print $1 ":" $6 ":0x" $7 ":" $8 " "}' 39) 40 41for tuple in $BRANCHES 42do 43 from=`echo $tuple | cut -d':' -f1` 44 branch=`echo $tuple | cut -d':' -f2` 45 to=`echo $tuple | cut -d':' -f3 | sed 's/cr[0-7],//'` 46 sym=`echo $tuple | cut -d':' -f4` 47 48 if (( $to > $end_intr )) 49 then 50 if [ -z "$bad_branches" ]; then 51 echo "WARNING: Unrelocated relative branches" 52 bad_branches="yes" 53 fi 54 echo "$from $branch-> $to $sym" 55 fi 56done 57 58if [ -z "$bad_branches" ]; then 59 exit 0 60fi 61