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