xref: /openbmc/linux/tools/objtool/sync-check.sh (revision bb090fdb70ecc51c91e1d86345adae064caa06c8)
13bd51c5aSJosh Poimboeuf#!/bin/sh
23bd51c5aSJosh Poimboeuf# SPDX-License-Identifier: GPL-2.0
33bd51c5aSJosh Poimboeuf
4*bb090fdbSJulien Thierryif [ -z "$SRCARCH" ]; then
5*bb090fdbSJulien Thierry	echo 'sync-check.sh: error: missing $SRCARCH environment variable' >&2
6*bb090fdbSJulien Thierry	exit 1
7*bb090fdbSJulien Thierryfi
8*bb090fdbSJulien Thierry
9*bb090fdbSJulien Thierryif [ "$SRCARCH" = "x86" ]; then
103890b8d9SJulien ThierryFILES="
113bd51c5aSJosh Poimboeufarch/x86/include/asm/inat_types.h
123bd51c5aSJosh Poimboeufarch/x86/include/asm/orc_types.h
134d65adfcSMasami Hiramatsuarch/x86/include/asm/emulate_prefix.h
14d046b725SJosh Poimboeufarch/x86/lib/x86-opcode-map.txt
15d046b725SJosh Poimboeufarch/x86/tools/gen-insn-attr-x86.awk
161e7e4788SJosh Poimboeufinclude/linux/static_call_types.h
173890b8d9SJulien Thierryarch/x86/include/asm/inat.h     -I '^#include [\"<]\(asm/\)*inat_types.h[\">]'
183890b8d9SJulien Thierryarch/x86/include/asm/insn.h     -I '^#include [\"<]\(asm/\)*inat.h[\">]'
193890b8d9SJulien Thierryarch/x86/lib/inat.c             -I '^#include [\"<]\(../include/\)*asm/insn.h[\">]'
203890b8d9SJulien Thierryarch/x86/lib/insn.c             -I '^#include [\"<]\(../include/\)*asm/in\(at\|sn\).h[\">]' -I '^#include [\"<]\(../include/\)*asm/emulate_prefix.h[\">]'
213890b8d9SJulien Thierry"
22*bb090fdbSJulien Thierryfi
233bd51c5aSJosh Poimboeuf
242ffd84aeSArnaldo Carvalho de Melocheck_2 () {
252ffd84aeSArnaldo Carvalho de Melo  file1=$1
262ffd84aeSArnaldo Carvalho de Melo  file2=$2
273bd51c5aSJosh Poimboeuf
282ffd84aeSArnaldo Carvalho de Melo  shift
292ffd84aeSArnaldo Carvalho de Melo  shift
302ffd84aeSArnaldo Carvalho de Melo
312ffd84aeSArnaldo Carvalho de Melo  cmd="diff $* $file1 $file2 > /dev/null"
322ffd84aeSArnaldo Carvalho de Melo
332ffd84aeSArnaldo Carvalho de Melo  test -f $file2 && {
342ffd84aeSArnaldo Carvalho de Melo    eval $cmd || {
352ffd84aeSArnaldo Carvalho de Melo      echo "Warning: Kernel ABI header at '$file1' differs from latest version at '$file2'" >&2
362ffd84aeSArnaldo Carvalho de Melo      echo diff -u $file1 $file2
372ffd84aeSArnaldo Carvalho de Melo    }
382ffd84aeSArnaldo Carvalho de Melo  }
392ffd84aeSArnaldo Carvalho de Melo}
402ffd84aeSArnaldo Carvalho de Melo
412ffd84aeSArnaldo Carvalho de Melocheck () {
422ffd84aeSArnaldo Carvalho de Melo  file=$1
432ffd84aeSArnaldo Carvalho de Melo
442ffd84aeSArnaldo Carvalho de Melo  shift
452ffd84aeSArnaldo Carvalho de Melo
462ffd84aeSArnaldo Carvalho de Melo  check_2 tools/$file $file $*
473bd51c5aSJosh Poimboeuf}
483bd51c5aSJosh Poimboeuf
493bd51c5aSJosh Poimboeufif [ ! -d ../../kernel ] || [ ! -d ../../tools ] || [ ! -d ../objtool ]; then
503bd51c5aSJosh Poimboeuf	exit 0
513bd51c5aSJosh Poimboeuffi
523bd51c5aSJosh Poimboeuf
532ffd84aeSArnaldo Carvalho de Melocd ../..
542ffd84aeSArnaldo Carvalho de Melo
553890b8d9SJulien Thierrywhile read -r file_entry; do
563890b8d9SJulien Thierry    if [ -z "$file_entry" ]; then
573890b8d9SJulien Thierry	continue
583890b8d9SJulien Thierry    fi
592ffd84aeSArnaldo Carvalho de Melo
603890b8d9SJulien Thierry    check $file_entry
613890b8d9SJulien Thierrydone <<EOF
623890b8d9SJulien Thierry$FILES
633890b8d9SJulien ThierryEOF
64