162306a36Sopenharmony_ci#!/bin/bash 262306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 362306a36Sopenharmony_ci 462306a36Sopenharmony_ciset -e 562306a36Sopenharmony_ciset -o pipefail 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci# To debug, uncomment the following line 862306a36Sopenharmony_ci# set -x 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci# Output from -fpatchable-function-entry can only vary on ppc64 elfv2, so this 1162306a36Sopenharmony_ci# should not be invoked for other targets. Therefore we can pass in -m64 and 1262306a36Sopenharmony_ci# -mabi explicitly, to take care of toolchains defaulting to other targets. 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci# Test whether the compile option -fpatchable-function-entry exists and 1562306a36Sopenharmony_ci# generates appropriate code 1662306a36Sopenharmony_ciecho "int func() { return 0; }" | \ 1762306a36Sopenharmony_ci $* -m64 -mabi=elfv2 -S -x c -O2 -fpatchable-function-entry=2 - -o - 2> /dev/null | \ 1862306a36Sopenharmony_ci grep -q "__patchable_function_entries" 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci# Test whether nops are generated after the local entry point 2162306a36Sopenharmony_ciecho "int x; int func() { return x; }" | \ 2262306a36Sopenharmony_ci $* -m64 -mabi=elfv2 -S -x c -O2 -fpatchable-function-entry=2 - -o - 2> /dev/null | \ 2362306a36Sopenharmony_ci awk 'BEGIN { RS = ";" } /\.localentry.*nop.*\n[[:space:]]*nop/ { print $0 }' | \ 2462306a36Sopenharmony_ci grep -q "func:" 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ciexit 0 27