2 # SPDX-License-Identifier: GPL-2.0
5 # This file is part of Lustre, http://www.lustre.org/
7 # rpm/find-provides.ksyms
9 # Find which kernel symbols a particular module provides
14 MODULE_SYMVERS=$RPM_BUILD_ROOT/Module.symvers
16 for module in $(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz)?$'); do
18 if [ "x${module%.ko}" = "x${module}" ]; then
19 tmpfile=$(mktemp -t ${0##*/}.XXXXXX.ko)
21 case "${module##*.}" in
33 [ -n "$proc_bin" ] || continue
35 "$proc_bin" -d -c - < "$module" > "$tmpfile" || continue
39 if [[ -f $MODULE_SYMVERS ]] ; then
40 # all symbols prefixed with __rcr_ where the symbol is:
41 # A - symbol is an absolute value
42 # D,d - symbol is in the initialized data section
43 # R,r - symbol is in the read-only data section
44 # T,t - symbol is in the text (code) section
45 for sym in $(nm $module | sed -r -ne 's:^0*([0-9a-f]+) [ADdRr] __crc_(.+):\2:p'); do
46 grep -w $sym $MODULE_SYMVERS | awk '{printf("ksym(%s) = %08s\n", $2, $1)}'
50 >&2 echo "Module.symvers required for provides."
52 [ -z "$tmpfile" ] || rm -f -- "$tmpfile"