diff options
author | Paul Gortmaker <paul.gortmaker@windriver.com> | 2015-04-20 10:20:26 +0930 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-05-08 07:44:12 +0200 |
commit | 0acdf4380cbdc9dbc8d49ee5063295f55873c91b (patch) | |
tree | 9e8e9ed7f0eba9e494821a65f2ea944ba140a5ce /scripts | |
parent | 5ef346991a5ec84169456fd71e117c8c62ab6958 (diff) | |
download | linux-stable-0acdf4380cbdc9dbc8d49ee5063295f55873c91b.tar.gz linux-stable-0acdf4380cbdc9dbc8d49ee5063295f55873c91b.tar.bz2 linux-stable-0acdf4380cbdc9dbc8d49ee5063295f55873c91b.zip |
modpost: expand pattern matching to support substring matches
commit 09c20c032b0f753969ae778d9783d946f054d7fe upstream.
Currently the match() function supports a leading * to match any
prefix and a trailing * to match any suffix. However there currently
is not a combination of both that can be used to target matches of
whole families of functions that share a common substring.
Here we expand the *foo and foo* match to also support *foo* with
the goal of targeting compiler generated symbol names that contain
strings like ".constprop." and ".isra."
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/mod/modpost.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index d439856f8176..688b93cc06fe 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -776,6 +776,7 @@ static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr) * "foo" will match an exact string equal to "foo" * "*foo" will match a string that ends with "foo" * "foo*" will match a string that begins with "foo" + * "*foo*" will match a string that contains "foo" */ static int match(const char *sym, const char * const pat[]) { @@ -784,8 +785,17 @@ static int match(const char *sym, const char * const pat[]) p = *pat++; const char *endp = p + strlen(p) - 1; + /* "*foo*" */ + if (*p == '*' && *endp == '*') { + char *here, *bare = strndup(p + 1, strlen(p) - 2); + + here = strstr(sym, bare); + free(bare); + if (here != NULL) + return 1; + } /* "*foo" */ - if (*p == '*') { + else if (*p == '*') { if (strrcmp(sym, p + 1) == 0) return 1; } |