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