summaryrefslogtreecommitdiff
path: root/tools/objtool/tests/generic/test-function-removal.sh
blob: df76e81e3936c48343a25477c62af41050a699af (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# A patch which deletes a function leaves a symbol in the original with no
# counterpart in the patched object.  klp diff cannot correlate it, and must
# say so and carry on: livepatching cannot remove code from a running kernel,
# so what matters is that the surviving caller is patched and the deleted
# function is not dragged into the patch module.
#
# Cloning it would be worse than useless -- dead code in the patch, plus
# whatever it references, resolved against a kernel where it may not exist.

. "$(dirname "$0")/../lib.sh"

setup
build_pair function_removal.c

# One-sided by construction: present in the original, gone from the patched.
has_input_symbol orig.o going_away ||
	fail "fixture has no going_away in the original"
has_input_symbol patched.o going_away &&
	fail "fixture still has going_away in the patched object"

run_diff

assert_diff_log 'no correlation: going_away'

# The caller changed, so it is patched ...
assert_patched caller
# ... and the deleted function comes along in no form at all.
assert_not_patched going_away
assert_no_symbol going_away

pass "deleted function reported as uncorrelated and left out of the patch"