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