xref: /linux/tools/objtool/tests/generic/test-new-data.sh (revision f4b8bfb1285992a6ab6f3d7cd25186d64f0773ee)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3#
4# Data added by the patch has no counterpart in the running kernel and must be
5# carried into the livepatch.
6
7. "$(dirname "$0")/../lib.sh"
8
9setup
10build_pair new_data.c
11
12# State the premise on both sides.  The array is new in the patched build and
13# absent from the original; if the compiler folded it into the code instead of
14# emitting it, the assertion below would fail without saying why.
15has_input_symbol "$orig_obj" klp_new_data &&
16	fail "fixture put klp_new_data in the original; nothing new to carry"
17has_input_symbol "$patched_obj" klp_new_data ||
18	fail "compiler did not emit klp_new_data; the fixture tests nothing"
19in_relocs "$patched_obj" | grep -q 'klp_new_data' ||
20	fail "target() does not reference klp_new_data; the fixture tests nothing"
21
22run_diff
23
24assert_patched target
25assert_symbol klp_new_data
26
27pass "new data carried into the patch"
28