xref: /linux/tools/objtool/sync-check.sh (revision 41d24d78589705f85cbe90e5a8c1b55ea05557a2)
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3
4if [ -z "$SRCARCH" ]; then
5	echo 'sync-check.sh: error: missing $SRCARCH environment variable' >&2
6	exit 1
7fi
8
9FILES="include/linux/objtool_types.h"
10
11if [ "$SRCARCH" = "x86" ]; then
12FILES="$FILES
13arch/x86/include/asm/nops.h
14arch/x86/include/asm/inat_types.h
15arch/x86/include/asm/orc_types.h
16arch/x86/include/asm/emulate_prefix.h
17arch/x86/lib/x86-opcode-map.txt
18arch/x86/tools/gen-insn-attr-x86.awk
19include/linux/interval_tree_generic.h
20include/linux/static_call_types.h
21"
22
23SYNC_CHECK_FILES='
24arch/x86/include/asm/inat.h
25arch/x86/include/asm/insn.h
26arch/x86/lib/inat.c
27arch/x86/lib/insn.c
28'
29fi
30
31check_2 () {
32  file1=$1
33  file2=$2
34
35  shift
36  shift
37
38  cmd="diff $* $file1 $file2 > /dev/null"
39
40  test -f $file2 && {
41    eval $cmd || {
42      echo "Warning: Kernel ABI header at '$file1' differs from latest version at '$file2'" >&2
43      echo diff -u $file1 $file2
44    }
45  }
46}
47
48check () {
49  file=$1
50
51  shift
52
53  check_2 tools/$file $file $*
54}
55
56if [ ! -d ../../kernel ] || [ ! -d ../../tools ] || [ ! -d ../objtool ]; then
57	exit 0
58fi
59
60cd ../..
61
62while read -r file_entry; do
63    if [ -z "$file_entry" ]; then
64	continue
65    fi
66
67    check $file_entry
68done <<EOF
69$FILES
70EOF
71
72if [ "$SRCARCH" = "x86" ]; then
73	for i in $SYNC_CHECK_FILES; do
74		check $i '-I "^.*\/\*.*__ignore_sync_check__.*\*\/.*$"'
75	done
76fi
77