1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0-or-later 3 4# Error out on error 5set -e 6 7num_ool_stubs_text_builtin="$1" 8is_64bit="$2" 9objdump="$3" 10vmlinux_o="$4" 11arch_vmlinux_S="$5" 12 13RELOCATION=R_PPC64_ADDR64 14if [ -z "$is_64bit" ]; then 15 RELOCATION=R_PPC_ADDR32 16fi 17 18num_ool_stubs_total=$($objdump -r -j __patchable_function_entries "$vmlinux_o" | 19 grep -c "$RELOCATION") 20num_ool_stubs_inittext=$($objdump -r -j __patchable_function_entries "$vmlinux_o" | 21 grep -e ".init.text" -e ".text.startup" | grep -c "$RELOCATION") 22num_ool_stubs_text=$((num_ool_stubs_total - num_ool_stubs_inittext)) 23 24if [ "$num_ool_stubs_text" -gt "$num_ool_stubs_text_builtin" ]; then 25 num_ool_stubs_text_end=$((num_ool_stubs_text - num_ool_stubs_text_builtin)) 26else 27 num_ool_stubs_text_end=0 28fi 29 30cat > "$arch_vmlinux_S" <<EOF 31#include <asm/asm-offsets.h> 32#include <asm/ppc_asm.h> 33#include <linux/linkage.h> 34 35.pushsection .tramp.ftrace.text,"aw" 36SYM_DATA(ftrace_ool_stub_text_end_count, .long $num_ool_stubs_text_end) 37 38SYM_START(ftrace_ool_stub_text_end, SYM_L_GLOBAL, .balign SZL) 39#if $num_ool_stubs_text_end 40 .space $num_ool_stubs_text_end * FTRACE_OOL_STUB_SIZE 41#endif 42SYM_CODE_END(ftrace_ool_stub_text_end) 43.popsection 44 45.pushsection .tramp.ftrace.init,"aw" 46SYM_DATA(ftrace_ool_stub_inittext_count, .long $num_ool_stubs_inittext) 47 48SYM_START(ftrace_ool_stub_inittext, SYM_L_GLOBAL, .balign SZL) 49 .space $num_ool_stubs_inittext * FTRACE_OOL_STUB_SIZE 50SYM_CODE_END(ftrace_ool_stub_inittext) 51.popsection 52EOF 53