xref: /linux/tools/objtool/tests/generic/test-function-removal.sh (revision 5b6dca02b3e2254d2fd5706d76d7ab4610a67296)
1*ade23d75SSong Liu#!/bin/bash
2*ade23d75SSong Liu# SPDX-License-Identifier: GPL-2.0
3*ade23d75SSong Liu#
4*ade23d75SSong Liu# A patch which deletes a function leaves a symbol in the original with no
5*ade23d75SSong Liu# counterpart in the patched object.  klp diff cannot correlate it, and must
6*ade23d75SSong Liu# say so and carry on: livepatching cannot remove code from a running kernel,
7*ade23d75SSong Liu# so what matters is that the surviving caller is patched and the deleted
8*ade23d75SSong Liu# function is not dragged into the patch module.
9*ade23d75SSong Liu#
10*ade23d75SSong Liu# Cloning it would be worse than useless -- dead code in the patch, plus
11*ade23d75SSong Liu# whatever it references, resolved against a kernel where it may not exist.
12*ade23d75SSong Liu
13*ade23d75SSong Liu. "$(dirname "$0")/../lib.sh"
14*ade23d75SSong Liu
15*ade23d75SSong Liusetup
16*ade23d75SSong Liubuild_pair function_removal.c
17*ade23d75SSong Liu
18*ade23d75SSong Liu# One-sided by construction: present in the original, gone from the patched.
19*ade23d75SSong Liuhas_input_symbol orig.o going_away ||
20*ade23d75SSong Liu	fail "fixture has no going_away in the original"
21*ade23d75SSong Liuhas_input_symbol patched.o going_away &&
22*ade23d75SSong Liu	fail "fixture still has going_away in the patched object"
23*ade23d75SSong Liu
24*ade23d75SSong Liurun_diff
25*ade23d75SSong Liu
26*ade23d75SSong Liuassert_diff_log 'no correlation: going_away'
27*ade23d75SSong Liu
28*ade23d75SSong Liu# The caller changed, so it is patched ...
29*ade23d75SSong Liuassert_patched caller
30*ade23d75SSong Liu# ... and the deleted function comes along in no form at all.
31*ade23d75SSong Liuassert_not_patched going_away
32*ade23d75SSong Liuassert_no_symbol going_away
33*ade23d75SSong Liu
34*ade23d75SSong Liupass "deleted function reported as uncorrelated and left out of the patch"
35