]> Git Repo - J-linux.git/blob - arch/powerpc/tools/ftrace_check.sh
Merge tag 'vfs-6.13-rc7.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
[J-linux.git] / arch / powerpc / tools / ftrace_check.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0-or-later
3 #
4 # This script checks vmlinux to ensure that all functions can call ftrace_caller() either directly,
5 # or through the stub, ftrace_tramp_text, at the end of kernel text.
6
7 # Error out if any command fails
8 set -e
9
10 # Allow for verbose output
11 if [ "$V" = "1" ]; then
12         set -x
13 fi
14
15 if [ $# -lt 2 ]; then
16         echo "$0 [path to nm] [path to vmlinux]" 1>&2
17         exit 1
18 fi
19
20 # Have Kbuild supply the path to nm so we handle cross compilation.
21 nm="$1"
22 vmlinux="$2"
23
24 stext_addr=$($nm "$vmlinux" | grep -e " [TA] _stext$" | \
25         cut -d' ' -f1 | tr '[:lower:]' '[:upper:]')
26 ftrace_caller_addr=$($nm "$vmlinux" | grep -e " T ftrace_caller$" | \
27         cut -d' ' -f1 | tr '[:lower:]' '[:upper:]')
28 ftrace_tramp_addr=$($nm "$vmlinux" | grep -e " T ftrace_tramp_text$" | \
29         cut -d' ' -f1 | tr '[:lower:]' '[:upper:]')
30
31 ftrace_caller_offset=$(echo "ibase=16;$ftrace_caller_addr - $stext_addr" | bc)
32 ftrace_tramp_offset=$(echo "ibase=16;$ftrace_tramp_addr - $ftrace_caller_addr" | bc)
33 sz_32m=$(printf "%d" 0x2000000)
34 sz_64m=$(printf "%d" 0x4000000)
35
36 # ftrace_caller - _stext < 32M
37 if [ "$ftrace_caller_offset" -ge "$sz_32m" ]; then
38         echo "ERROR: ftrace_caller (0x$ftrace_caller_addr) is beyond 32MiB of _stext" 1>&2
39         echo "ERROR: consider disabling CONFIG_FUNCTION_TRACER, or reducing the size \
40                 of kernel text" 1>&2
41         exit 1
42 fi
43
44 # ftrace_tramp_text - ftrace_caller < 64M
45 if [ "$ftrace_tramp_offset" -ge "$sz_64m" ]; then
46         echo "ERROR: kernel text extends beyond 64MiB from ftrace_caller" 1>&2
47         echo "ERROR: consider disabling CONFIG_FUNCTION_TRACER, or reducing the size \
48                 of kernel text" 1>&2
49         exit 1
50 fi
This page took 0.029075 seconds and 4 git commands to generate.