xref: /openbmc/linux/arch/riscv/tools/relocs_check.sh (revision c2dea0bc)
1*c2dea0bcSAlexandre Ghiti#!/bin/sh
2*c2dea0bcSAlexandre Ghiti# SPDX-License-Identifier: GPL-2.0-or-later
3*c2dea0bcSAlexandre Ghiti# Based on powerpc relocs_check.sh
4*c2dea0bcSAlexandre Ghiti
5*c2dea0bcSAlexandre Ghiti# This script checks the relocations of a vmlinux for "suspicious"
6*c2dea0bcSAlexandre Ghiti# relocations.
7*c2dea0bcSAlexandre Ghiti
8*c2dea0bcSAlexandre Ghitiif [ $# -lt 3 ]; then
9*c2dea0bcSAlexandre Ghiti        echo "$0 [path to objdump] [path to nm] [path to vmlinux]" 1>&2
10*c2dea0bcSAlexandre Ghiti        exit 1
11*c2dea0bcSAlexandre Ghitifi
12*c2dea0bcSAlexandre Ghiti
13*c2dea0bcSAlexandre Ghitibad_relocs=$(
14*c2dea0bcSAlexandre Ghiti${srctree}/scripts/relocs_check.sh "$@" |
15*c2dea0bcSAlexandre Ghiti	# These relocations are okay
16*c2dea0bcSAlexandre Ghiti	#	R_RISCV_RELATIVE
17*c2dea0bcSAlexandre Ghiti	grep -F -w -v 'R_RISCV_RELATIVE'
18*c2dea0bcSAlexandre Ghiti)
19*c2dea0bcSAlexandre Ghiti
20*c2dea0bcSAlexandre Ghitiif [ -z "$bad_relocs" ]; then
21*c2dea0bcSAlexandre Ghiti	exit 0
22*c2dea0bcSAlexandre Ghitifi
23*c2dea0bcSAlexandre Ghiti
24*c2dea0bcSAlexandre Ghitinum_bad=$(echo "$bad_relocs" | wc -l)
25*c2dea0bcSAlexandre Ghitiecho "WARNING: $num_bad bad relocations"
26*c2dea0bcSAlexandre Ghitiecho "$bad_relocs"
27