xref: /openbmc/linux/tools/objtool/sync-check.sh (revision 301cddc21a157a3072d789a3097857202e550a24)
13bd51c5aSJosh Poimboeuf#!/bin/sh
23bd51c5aSJosh Poimboeuf# SPDX-License-Identifier: GPL-2.0
33bd51c5aSJosh Poimboeuf
4bb090fdbSJulien Thierryif [ -z "$SRCARCH" ]; then
5bb090fdbSJulien Thierry	echo 'sync-check.sh: error: missing $SRCARCH environment variable' >&2
6bb090fdbSJulien Thierry	exit 1
7bb090fdbSJulien Thierryfi
8bb090fdbSJulien Thierry
9ee819aedSJulien ThierryFILES="include/linux/objtool.h"
10ee819aedSJulien Thierry
11bb090fdbSJulien Thierryif [ "$SRCARCH" = "x86" ]; then
12ee819aedSJulien ThierryFILES="$FILES
13*301cddc2SPeter Zijlstraarch/x86/include/asm/nops.h
143bd51c5aSJosh Poimboeufarch/x86/include/asm/inat_types.h
153bd51c5aSJosh Poimboeufarch/x86/include/asm/orc_types.h
164d65adfcSMasami Hiramatsuarch/x86/include/asm/emulate_prefix.h
17d046b725SJosh Poimboeufarch/x86/lib/x86-opcode-map.txt
18d046b725SJosh Poimboeufarch/x86/tools/gen-insn-attr-x86.awk
191e7e4788SJosh Poimboeufinclude/linux/static_call_types.h
203890b8d9SJulien Thierryarch/x86/include/asm/inat.h     -I '^#include [\"<]\(asm/\)*inat_types.h[\">]'
213890b8d9SJulien Thierryarch/x86/include/asm/insn.h     -I '^#include [\"<]\(asm/\)*inat.h[\">]'
223890b8d9SJulien Thierryarch/x86/lib/inat.c             -I '^#include [\"<]\(../include/\)*asm/insn.h[\">]'
233890b8d9SJulien Thierryarch/x86/lib/insn.c             -I '^#include [\"<]\(../include/\)*asm/in\(at\|sn\).h[\">]' -I '^#include [\"<]\(../include/\)*asm/emulate_prefix.h[\">]'
243890b8d9SJulien Thierry"
25bb090fdbSJulien Thierryfi
263bd51c5aSJosh Poimboeuf
272ffd84aeSArnaldo Carvalho de Melocheck_2 () {
282ffd84aeSArnaldo Carvalho de Melo  file1=$1
292ffd84aeSArnaldo Carvalho de Melo  file2=$2
303bd51c5aSJosh Poimboeuf
312ffd84aeSArnaldo Carvalho de Melo  shift
322ffd84aeSArnaldo Carvalho de Melo  shift
332ffd84aeSArnaldo Carvalho de Melo
342ffd84aeSArnaldo Carvalho de Melo  cmd="diff $* $file1 $file2 > /dev/null"
352ffd84aeSArnaldo Carvalho de Melo
362ffd84aeSArnaldo Carvalho de Melo  test -f $file2 && {
372ffd84aeSArnaldo Carvalho de Melo    eval $cmd || {
382ffd84aeSArnaldo Carvalho de Melo      echo "Warning: Kernel ABI header at '$file1' differs from latest version at '$file2'" >&2
392ffd84aeSArnaldo Carvalho de Melo      echo diff -u $file1 $file2
402ffd84aeSArnaldo Carvalho de Melo    }
412ffd84aeSArnaldo Carvalho de Melo  }
422ffd84aeSArnaldo Carvalho de Melo}
432ffd84aeSArnaldo Carvalho de Melo
442ffd84aeSArnaldo Carvalho de Melocheck () {
452ffd84aeSArnaldo Carvalho de Melo  file=$1
462ffd84aeSArnaldo Carvalho de Melo
472ffd84aeSArnaldo Carvalho de Melo  shift
482ffd84aeSArnaldo Carvalho de Melo
492ffd84aeSArnaldo Carvalho de Melo  check_2 tools/$file $file $*
503bd51c5aSJosh Poimboeuf}
513bd51c5aSJosh Poimboeuf
523bd51c5aSJosh Poimboeufif [ ! -d ../../kernel ] || [ ! -d ../../tools ] || [ ! -d ../objtool ]; then
533bd51c5aSJosh Poimboeuf	exit 0
543bd51c5aSJosh Poimboeuffi
553bd51c5aSJosh Poimboeuf
562ffd84aeSArnaldo Carvalho de Melocd ../..
572ffd84aeSArnaldo Carvalho de Melo
583890b8d9SJulien Thierrywhile read -r file_entry; do
593890b8d9SJulien Thierry    if [ -z "$file_entry" ]; then
603890b8d9SJulien Thierry	continue
613890b8d9SJulien Thierry    fi
622ffd84aeSArnaldo Carvalho de Melo
633890b8d9SJulien Thierry    check $file_entry
643890b8d9SJulien Thierrydone <<EOF
653890b8d9SJulien Thierry$FILES
663890b8d9SJulien ThierryEOF
67