xref: /openbmc/linux/tools/objtool/sync-check.sh (revision bb090fdb70ecc51c91e1d86345adae064caa06c8)
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
9if [ "$SRCARCH" = "x86" ]; then
10FILES="
11arch/x86/include/asm/inat_types.h
12arch/x86/include/asm/orc_types.h
13arch/x86/include/asm/emulate_prefix.h
14arch/x86/lib/x86-opcode-map.txt
15arch/x86/tools/gen-insn-attr-x86.awk
16include/linux/static_call_types.h
17arch/x86/include/asm/inat.h     -I '^#include [\"<]\(asm/\)*inat_types.h[\">]'
18arch/x86/include/asm/insn.h     -I '^#include [\"<]\(asm/\)*inat.h[\">]'
19arch/x86/lib/inat.c             -I '^#include [\"<]\(../include/\)*asm/insn.h[\">]'
20arch/x86/lib/insn.c             -I '^#include [\"<]\(../include/\)*asm/in\(at\|sn\).h[\">]' -I '^#include [\"<]\(../include/\)*asm/emulate_prefix.h[\">]'
21"
22fi
23
24check_2 () {
25  file1=$1
26  file2=$2
27
28  shift
29  shift
30
31  cmd="diff $* $file1 $file2 > /dev/null"
32
33  test -f $file2 && {
34    eval $cmd || {
35      echo "Warning: Kernel ABI header at '$file1' differs from latest version at '$file2'" >&2
36      echo diff -u $file1 $file2
37    }
38  }
39}
40
41check () {
42  file=$1
43
44  shift
45
46  check_2 tools/$file $file $*
47}
48
49if [ ! -d ../../kernel ] || [ ! -d ../../tools ] || [ ! -d ../objtool ]; then
50	exit 0
51fi
52
53cd ../..
54
55while read -r file_entry; do
56    if [ -z "$file_entry" ]; then
57	continue
58    fi
59
60    check $file_entry
61done <<EOF
62$FILES
63EOF
64