xref: /linux/tools/objtool/tests/generic/test-modname-normalize.sh (revision 35021df3834e0b51dd77e4be6ee7cbe9bcfa4825)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3#
4# Module.symvers records the build-tree path of the object that exports a
5# symbol, not the name the module has at runtime: "arch/x86/kvm/kvm-intel",
6# where the kernel knows the module as "kvm_intel".
7#
8# The klp symbol name embeds the owning object, and livepatch matches it
9# against loaded modules by name.  Left unnormalized it names a module that
10# does not exist, and the relocation is never resolved -- at load time, with no
11# build-time complaint.
12
13. "$(dirname "$0")/../lib.sh"
14
15setup
16build_module_pair cross_module.c klp_testmod
17
18# A path with directory components, a dash, and no extension.
19export_syms
20add_exports "arch/x86/kvm/kvm-intel" other_mod_func
21run_diff
22
23# Directories stripped, dash to underscore.
24assert_klp_sym other_mod_func kvm_intel
25
26pass "Module.symvers paths normalized to runtime module names"
27