]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - scripts/gen_autoksyms.sh
PCI: aardvark: Enable MSI-X support
[mirror_ubuntu-jammy-kernel.git] / scripts / gen_autoksyms.sh
CommitLineData
cd195bc4
QP
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-only
3
4# Create an autoksyms.h header file from the list of all module's needed symbols
5# as recorded on the second line of *.mod files and the user-provided symbol
6# whitelist.
7
8set -e
9
10output_file="$1"
11
12# Use "make V=1" to debug this script.
13case "$KBUILD_VERBOSE" in
14*1*)
15 set -x
16 ;;
17esac
18
19# We need access to CONFIG_ symbols
20. include/config/auto.conf
21
a6aaeb84
MY
22needed_symbols=
23
24# Special case for modversions (see modpost.c)
25if [ -n "$CONFIG_MODVERSIONS" ]; then
26 needed_symbols="$needed_symbols module_layout"
27fi
28
a6aaeb84 29ksym_wl=
cd195bc4
QP
30if [ -n "$CONFIG_UNUSED_KSYMS_WHITELIST" ]; then
31 # Use 'eval' to expand the whitelist path and check if it is relative
32 eval ksym_wl="$CONFIG_UNUSED_KSYMS_WHITELIST"
33 [ "${ksym_wl}" != "${ksym_wl#/}" ] || ksym_wl="$abs_srctree/$ksym_wl"
34 if [ ! -f "$ksym_wl" ] || [ ! -r "$ksym_wl" ]; then
35 echo "ERROR: '$ksym_wl' whitelist file not found" >&2
36 exit 1
37 fi
38fi
39
40# Generate a new ksym list file with symbols needed by the current
41# set of modules.
42cat > "$output_file" << EOT
43/*
44 * Automatically generated file; DO NOT EDIT.
45 */
46
47EOT
48
88694cff 49[ -f modules.order ] && modlist=modules.order || modlist=/dev/null
a6aaeb84
MY
50
51{
52 sed 's/ko$/mod/' $modlist | xargs -n1 sed -n -e '2p'
53 echo "$needed_symbols"
54 [ -n "$ksym_wl" ] && cat "$ksym_wl"
55} | sed -e 's/ /\n/g' | sed -n -e '/^$/!p' |
29500f15
MY
56# Remove the dot prefix for ppc64; symbol names with a dot (.) hold entry
57# point addresses.
58sed -e 's/^\.//' |
cd195bc4
QP
59sort -u |
60sed -e 's/\(.*\)/#define __KSYM_\1 1/' >> "$output_file"