File built-in-where of Package kernel-source

#! /bin/bash

sourcedir=${0%/*}

# A lot of symbols are exported by the main kernel image. Find out
# more precisely which built-in.o file defines them, and fill in
# that information in Module.symvers. (The built-in.o files are
# linked together from one or more object files in a directory.)
#   We use this information to better group symbols by subsystems.
#
# Usage: built-in-where [-j<jobs>] < Module.symvers

unset LANG ${!LC_*}
make_opts=($@)

# Create a table of all symbol export in a built-in.o file, e.g.,
# 0xc87c1f84   ktime_get   kernel/built-in   EXPORT_SYMBOL_GPL
built_in_exports() {
    find -name '.directory_symbols' -delete
    make "${make_opts[@]}" -s -rR --no-print-directory \
	-f $sourcedir/built-in-where.mk obj=.
    cat .directory_symbols
    find -name '.directory_symbols' -delete
}

# Filter out duplicates from a Module.symvers dump
unique_symbols() {
    awk '!seen[$2]++'
}

# Join together the two tables, including all lines from the first
# file that don't have a match in the second.
# Finally, remove the duplicate columns.
join -t $'\t' -j 2 -a 1 \
    <(sort -k2) \
    <(built_in_exports | unique_symbols | sort -k2) \
| awk '
BEGIN	{ FS = "\t" ; OFS = "\t" }
NF == 7 { print $2, $1, $6, $4 }
NF == 4 { print $2, $1, $3, $4 }
'