1*0f71dcfbSNaveen N Rao#!/bin/bash 2*0f71dcfbSNaveen N Rao# SPDX-License-Identifier: GPL-2.0 3*0f71dcfbSNaveen N Rao 4*0f71dcfbSNaveen N Raoset -e 5*0f71dcfbSNaveen N Raoset -o pipefail 6*0f71dcfbSNaveen N Rao 7*0f71dcfbSNaveen N Rao# To debug, uncomment the following line 8*0f71dcfbSNaveen N Rao# set -x 9*0f71dcfbSNaveen N Rao 10*0f71dcfbSNaveen N Rao# Output from -fpatchable-function-entry can only vary on ppc64 elfv2, so this 11*0f71dcfbSNaveen N Rao# should not be invoked for other targets. Therefore we can pass in -m64 and 12*0f71dcfbSNaveen N Rao# -mabi explicitly, to take care of toolchains defaulting to other targets. 13*0f71dcfbSNaveen N Rao 14*0f71dcfbSNaveen N Rao# Test whether the compile option -fpatchable-function-entry exists and 15*0f71dcfbSNaveen N Rao# generates appropriate code 16*0f71dcfbSNaveen N Raoecho "int func() { return 0; }" | \ 17*0f71dcfbSNaveen N Rao $* -m64 -mabi=elfv2 -S -x c -O2 -fpatchable-function-entry=2 - -o - 2> /dev/null | \ 18*0f71dcfbSNaveen N Rao grep -q "__patchable_function_entries" 19*0f71dcfbSNaveen N Rao 20*0f71dcfbSNaveen N Rao# Test whether nops are generated after the local entry point 21*0f71dcfbSNaveen N Raoecho "int x; int func() { return x; }" | \ 22*0f71dcfbSNaveen N Rao $* -m64 -mabi=elfv2 -S -x c -O2 -fpatchable-function-entry=2 - -o - 2> /dev/null | \ 23*0f71dcfbSNaveen N Rao awk 'BEGIN { RS = ";" } /\.localentry.*nop.*\n[[:space:]]*nop/ { print $0 }' | \ 24*0f71dcfbSNaveen N Rao grep -q "func:" 25*0f71dcfbSNaveen N Rao 26*0f71dcfbSNaveen N Raoexit 0 27