Created
July 14, 2019 12:51
-
-
Save evdenis/bf2322d094f0c02c0f60fe0a225848b2 to your computer and use it in GitHub Desktop.
Check that exported symbols in the Linux kernel are global
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# SPDX-License-Identifier: GPL-2.0 | |
# check_static_export.pl - check that exported symbols are global | |
# (c) 2019 Denis Efremov <efremov@linux.com> | |
use strict; | |
use warnings; | |
foreach (@ARGV) { | |
my %symb; | |
foreach (`nm $_`) { | |
if (m/^(?<addr>[\da-f]++)?\h++(?<type>\w) (?<name>[\w\.]++)$/) { | |
push @{$symb{$+{name}}}, { | |
addr => $+{addr}, | |
type => $+{type} | |
}; | |
} else { | |
warn "Can't parse the line $_\n"; | |
} | |
} | |
foreach (keys %symb) { | |
if (m/^__ksymtab_(?<name>\w++)$/) { | |
my $name = $+{name}; | |
if (exists $symb{$name}) { | |
my $static = 1; | |
foreach (@{$symb{$name}}) { | |
if ($_->{type} eq uc($_->{type})) { | |
$static = 0; | |
} | |
} | |
warn "WARNING: \"$name\" is the static EXPORT_SYMBOL\n" | |
if $static; | |
} else { | |
warn "Can't find symbol $name\n"; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment