1
0
forked from pool/kernel-source
kernel-source/built-in-where

33 lines
1.0 KiB
Bash

#! /bin/bash
# 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.,
# mtrr_add arch/i386/kernel/cpu/mtrr/built-in
built_in_exports() {
for obj in $(find -name built-in.o -printf '%P\n'); do
nm $obj \
| sed -nre 's:(00000000)?([0-9a-f]+) A __crc_(.*):\3\t'"${obj%.o}:p"
done
}
# 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 column.
join -t $'\t' -1 2 -2 1 -a 1 \
<(cut -f1,2,3 | sort -k2) \
<(built_in_exports | sort -k1) \
| awk '
BEGIN { FS = "\t" ; OFS = "\t" }
NF == 3 { print $2, $1, $3 }
NF == 4 { print $2, $1, $4 }
'