aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mod/modpost.c
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2017-09-06 19:19:05 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-09-06 20:27:24 -0400
commit6124c04c1344497e0cbfb505ddbd3b83090a4d51 (patch)
treec65330ad4030cfaddd016d4e6bebeca9b8dc0208 /scripts/mod/modpost.c
parent2f52074d35135ecf3fb719f3430d72c17ae07287 (diff)
modpost: simplify sec_name()
There is code duplication between sec_name() and sech_name(). Simplify sec_name() by re-using sech_name(). Also, move them up to remove the forward declaration of sec_name(). Link: http://lkml.kernel.org/r/1502248721-22009-1-git-send-email-yamada.masahiro@socionext.com Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Kees Cook <keescook@chromium.org> Cc: Nicholas Piggin <npiggin@gmail.com> Cc: Jessica Yu <jeyu@redhat.com> Cc: Chris Metcalf <cmetcalf@mellanox.com> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> Cc: Ingo Molnar <mingo@kernel.org> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/mod/modpost.c')
-rw-r--r--scripts/mod/modpost.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 48397feb08fb..b920d186ad4a 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -261,7 +261,17 @@ static enum export export_no(const char *s)
261 return export_unknown; 261 return export_unknown;
262} 262}
263 263
264static const char *sec_name(struct elf_info *elf, int secindex); 264static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr)
265{
266 return (void *)elf->hdr +
267 elf->sechdrs[elf->secindex_strings].sh_offset +
268 sechdr->sh_name;
269}
270
271static const char *sec_name(struct elf_info *elf, int secindex)
272{
273 return sech_name(elf, &elf->sechdrs[secindex]);
274}
265 275
266#define strstarts(str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0) 276#define strstarts(str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0)
267 277
@@ -775,21 +785,6 @@ static const char *sym_name(struct elf_info *elf, Elf_Sym *sym)
775 return "(unknown)"; 785 return "(unknown)";
776} 786}
777 787
778static const char *sec_name(struct elf_info *elf, int secindex)
779{
780 Elf_Shdr *sechdrs = elf->sechdrs;
781 return (void *)elf->hdr +
782 elf->sechdrs[elf->secindex_strings].sh_offset +
783 sechdrs[secindex].sh_name;
784}
785
786static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr)
787{
788 return (void *)elf->hdr +
789 elf->sechdrs[elf->secindex_strings].sh_offset +
790 sechdr->sh_name;
791}
792
793/* The pattern is an array of simple patterns. 788/* The pattern is an array of simple patterns.
794 * "foo" will match an exact string equal to "foo" 789 * "foo" will match an exact string equal to "foo"
795 * "*foo" will match a string that ends with "foo" 790 * "*foo" will match a string that ends with "foo"