summaryrefstree
path: root/kernel/scripts/checkup_jopp.sh
blob: ffa2d9561efec9fc8a222061b482695607ae8ce3 (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
#!/bin/sh
# Examine vmlinux file if it has correct JOPP magic.
# It will check if a leading instruction of start_kernel() is JOPP magic.
elf_file=${1}
jopp_magic=${2}

if [ -z $elf_file ] || [ -z $jopp_magic ]; then
	echo "checkup_jopp: invalid argument"
	exit 0
fi

addr=`${OBJDUMP} -t ${elf_file} | grep -w start_kernel`
addr=${addr%% *}

# reduce size to treat as number
addr_n=$((0x${addr#ffffff}))

# subtract and make format ffffffxxxxxxxxxx
target_addr=`printf "ffffff%010x" $(($addr_n - 4))`

${OBJDUMP} --start-address=0x${target_addr} --stop-address=0x${addr} -d $elf_file | tail -n 1 | grep -qi $jopp_magic

if [ $? -ne "0" ]; then
	echo "Error: Can't find JOPP magic(${jopp_magic}) at address 0x${target_addr} in vmlinux symbol"
	exit 1
fi