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