xref: /linux/tools/objtool/tests/generic/test-module-object.sh (revision 2d17a35f6c9489884e6a5ff7cb0d6b150d413371)
1*2d17a35fSSong Liu#!/bin/bash
2*2d17a35fSSong Liu# SPDX-License-Identifier: GPL-2.0
3*2d17a35fSSong Liu#
4*2d17a35fSSong Liu# A klp relocation section is named for the object being patched, not for the
5*2d17a35fSSong Liu# object which happens to own the symbol being referenced.  Deriving it from
6*2d17a35fSSong Liu# the symbol means a cross-module reference lands in a section for an object
7*2d17a35fSSong Liu# the patch may not even touch, so the relocation is never applied and the call
8*2d17a35fSSong Liu# goes somewhere arbitrary.
9*2d17a35fSSong Liu
10*2d17a35fSSong Liu. "$(dirname "$0")/../lib.sh"
11*2d17a35fSSong Liu
12*2d17a35fSSong Liusetup
13*2d17a35fSSong Liubuild_module_pair cross_module.c klp_testmod
14*2d17a35fSSong Liu
15*2d17a35fSSong Liu# The fixture has to have built as a module for any of this to mean anything.
16*2d17a35fSSong Liuin_sections orig.o | grep -q '\.modinfo' ||
17*2d17a35fSSong Liu	fail "fixture has no .modinfo"
18*2d17a35fSSong Liu
19*2d17a35fSSong Liu# other_mod_func belongs to a different module than the one being patched.
20*2d17a35fSSong Liuadd_exports other_mod other_mod_func
21*2d17a35fSSong Liurun_diff
22*2d17a35fSSong Liu
23*2d17a35fSSong Liu# Named for the patched object ...
24*2d17a35fSSong Liuassert_section __klp_relocs.klp_testmod
25*2d17a35fSSong Liu# ... not for the object owning the symbol.
26*2d17a35fSSong Liuassert_no_section __klp_relocs.other_mod
27*2d17a35fSSong Liu
28*2d17a35fSSong Liurun_post_link
29*2d17a35fSSong Liuassert_klp_rela klp_testmod .text.target
30*2d17a35fSSong Liu
31*2d17a35fSSong Liupass "klp relocation section named for the patched object"
32