aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mod/modpost.c
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2018-05-09 05:50:38 -0400
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-05-17 09:44:59 -0400
commitd62c476521a63053cb28d76ac50e02c2d13b1619 (patch)
tree1bcd58363f7b3b5341cd5966788cd601c5e38c4e /scripts/mod/modpost.c
parentbca2ccee4c4ac69496d3c8655d7869122fe5aeab (diff)
modpost: use strstarts() helper more widely
Currently, strstarts() is only used in export_from_secname(). Use it more widely to improve the code readability. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'scripts/mod/modpost.c')
-rw-r--r--scripts/mod/modpost.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 37a6a0b42846..8606b6caa21b 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -596,19 +596,19 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname)
596 return 1; 596 return 1;
597 if (info->hdr->e_machine == EM_PPC) 597 if (info->hdr->e_machine == EM_PPC)
598 /* Special register function linked on all modules during final link of .ko */ 598 /* Special register function linked on all modules during final link of .ko */
599 if (strncmp(symname, "_restgpr_", sizeof("_restgpr_") - 1) == 0 || 599 if (strstarts(symname, "_restgpr_") ||
600 strncmp(symname, "_savegpr_", sizeof("_savegpr_") - 1) == 0 || 600 strstarts(symname, "_savegpr_") ||
601 strncmp(symname, "_rest32gpr_", sizeof("_rest32gpr_") - 1) == 0 || 601 strstarts(symname, "_rest32gpr_") ||
602 strncmp(symname, "_save32gpr_", sizeof("_save32gpr_") - 1) == 0 || 602 strstarts(symname, "_save32gpr_") ||
603 strncmp(symname, "_restvr_", sizeof("_restvr_") - 1) == 0 || 603 strstarts(symname, "_restvr_") ||
604 strncmp(symname, "_savevr_", sizeof("_savevr_") - 1) == 0) 604 strstarts(symname, "_savevr_"))
605 return 1; 605 return 1;
606 if (info->hdr->e_machine == EM_PPC64) 606 if (info->hdr->e_machine == EM_PPC64)
607 /* Special register function linked on all modules during final link of .ko */ 607 /* Special register function linked on all modules during final link of .ko */
608 if (strncmp(symname, "_restgpr0_", sizeof("_restgpr0_") - 1) == 0 || 608 if (strstarts(symname, "_restgpr0_") ||
609 strncmp(symname, "_savegpr0_", sizeof("_savegpr0_") - 1) == 0 || 609 strstarts(symname, "_savegpr0_") ||
610 strncmp(symname, "_restvr_", sizeof("_restvr_") - 1) == 0 || 610 strstarts(symname, "_restvr_") ||
611 strncmp(symname, "_savevr_", sizeof("_savevr_") - 1) == 0 || 611 strstarts(symname, "_savevr_") ||
612 strcmp(symname, ".TOC.") == 0) 612 strcmp(symname, ".TOC.") == 0)
613 return 1; 613 return 1;
614 /* Do not ignore this symbol */ 614 /* Do not ignore this symbol */
@@ -623,13 +623,13 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
623 bool is_crc = false; 623 bool is_crc = false;
624 624
625 if ((!is_vmlinux(mod->name) || mod->is_dot_o) && 625 if ((!is_vmlinux(mod->name) || mod->is_dot_o) &&
626 strncmp(symname, "__ksymtab", 9) == 0) 626 strstarts(symname, "__ksymtab"))
627 export = export_from_secname(info, get_secindex(info, sym)); 627 export = export_from_secname(info, get_secindex(info, sym));
628 else 628 else
629 export = export_from_sec(info, get_secindex(info, sym)); 629 export = export_from_sec(info, get_secindex(info, sym));
630 630
631 /* CRC'd symbol */ 631 /* CRC'd symbol */
632 if (strncmp(symname, "__crc_", strlen("__crc_")) == 0) { 632 if (strstarts(symname, "__crc_")) {
633 is_crc = true; 633 is_crc = true;
634 crc = (unsigned int) sym->st_value; 634 crc = (unsigned int) sym->st_value;
635 if (sym->st_shndx != SHN_UNDEF && sym->st_shndx != SHN_ABS) { 635 if (sym->st_shndx != SHN_UNDEF && sym->st_shndx != SHN_ABS) {
@@ -648,7 +648,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
648 648
649 switch (sym->st_shndx) { 649 switch (sym->st_shndx) {
650 case SHN_COMMON: 650 case SHN_COMMON:
651 if (!strncmp(symname, "__gnu_lto_", sizeof("__gnu_lto_")-1)) { 651 if (strstarts(symname, "__gnu_lto_")) {
652 /* Should warn here, but modpost runs before the linker */ 652 /* Should warn here, but modpost runs before the linker */
653 } else 653 } else
654 warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name); 654 warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name);
@@ -691,7 +691,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
691 break; 691 break;
692 default: 692 default:
693 /* All exported symbols */ 693 /* All exported symbols */
694 if (strncmp(symname, "__ksymtab_", strlen("__ksymtab_")) == 0) { 694 if (strstarts(symname, "__ksymtab_")) {
695 sym_add_exported(symname + strlen("__ksymtab_"), mod, 695 sym_add_exported(symname + strlen("__ksymtab_"), mod,
696 export); 696 export);
697 } 697 }
@@ -1171,13 +1171,13 @@ static int secref_whitelist(const struct sectioncheck *mismatch,
1171 /* Check for pattern 1 */ 1171 /* Check for pattern 1 */
1172 if (match(tosec, init_data_sections) && 1172 if (match(tosec, init_data_sections) &&
1173 match(fromsec, data_sections) && 1173 match(fromsec, data_sections) &&
1174 (strncmp(fromsym, "__param", strlen("__param")) == 0)) 1174 strstarts(fromsym, "__param"))
1175 return 0; 1175 return 0;
1176 1176
1177 /* Check for pattern 1a */ 1177 /* Check for pattern 1a */
1178 if (strcmp(tosec, ".init.text") == 0 && 1178 if (strcmp(tosec, ".init.text") == 0 &&
1179 match(fromsec, data_sections) && 1179 match(fromsec, data_sections) &&
1180 (strncmp(fromsym, "__param_ops_", strlen("__param_ops_")) == 0)) 1180 strstarts(fromsym, "__param_ops_"))
1181 return 0; 1181 return 0;
1182 1182
1183 /* Check for pattern 2 */ 1183 /* Check for pattern 2 */
@@ -1532,8 +1532,7 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
1532 from = find_elf_symbol2(elf, r->r_offset, fromsec); 1532 from = find_elf_symbol2(elf, r->r_offset, fromsec);
1533 fromsym = sym_name(elf, from); 1533 fromsym = sym_name(elf, from);
1534 1534
1535 if (!strncmp(fromsym, "reference___initcall", 1535 if (strstarts(fromsym, "reference___initcall"))
1536 sizeof("reference___initcall")-1))
1537 return; 1536 return;
1538 1537
1539 tosec = sec_name(elf, get_secindex(elf, sym)); 1538 tosec = sec_name(elf, get_secindex(elf, sym));
@@ -2163,9 +2162,7 @@ static void add_retpoline(struct buffer *b)
2163 2162
2164static void add_staging_flag(struct buffer *b, const char *name) 2163static void add_staging_flag(struct buffer *b, const char *name)
2165{ 2164{
2166 static const char *staging_dir = "drivers/staging"; 2165 if (strstarts(name, "drivers/staging"))
2167
2168 if (strncmp(staging_dir, name, strlen(staging_dir)) == 0)
2169 buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n"); 2166 buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n");
2170} 2167}
2171 2168