kernel-source/built-in-where

57 lines
1.7 KiB
Plaintext
Raw Normal View History

#! /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 < Module.symvers
unset LANG ${!LC_*}
# 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() {
# a/b/c/built-in.o gets linked into a/b/built-in.o, so ensure
# that we visit sub-directories first to split up symbols as
# much as possible.
for obj in $(find -name built-in.o -printf '%d %P\n' \
| sort -r \
| awk '{ print $2 }'); do
$sourcedir/list-exported-symbols -n ${obj%.o} $obj
done
# We could go through the libraries as well, but those functions
# are so unlikely to change that this wouldn't help.
# (All remaining symbols will end up in the vmlinux set.)
#for archive in $(find -name '*.a'); do
# $sourcedir/list-exported-symbols -n ${archive%.a} $archive
#done
}
# Filter out duplicates from a Module.symvers dump
unique_symbols() {
awk '
{ if ($2 in seen)
next
seen[$2] = 1
print
}
'
}
# 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 }
'