diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-06 14:00:15 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-06 14:00:15 -0400 |
commit | 8715ee75fe6fa3aed367f28aa7a3655e6a8e4688 (patch) | |
tree | 192c25a109a73ca67d4483d89ee576660bb5f29c /scripts/mod | |
parent | 126f7051b4daa3716d9af2851dcb55316e4c2b25 (diff) | |
parent | 1f2f01b122d7c78a9e842a126ef168afb279552b (diff) |
Merge tag 'kbuild-v4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild updates from Masahiro Yamada:
- improve fixdep to coalesce consecutive slashes in dep-files
- fix some issues of the maintainer string generation in deb-pkg script
- remove unused CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX and clean-up
several tools and linker scripts
- clean-up modpost
- allow to enable the dead code/data elimination for PowerPC in EXPERT
mode
- improve two coccinelle scripts for better performance
- pass endianness and machine size flags to sparse for all architecture
- misc fixes
* tag 'kbuild-v4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (25 commits)
kbuild: add machine size to CHECKFLAGS
kbuild: add endianness flag to CHEKCFLAGS
kbuild: $(CHECK) doesnt need NOSTDINC_FLAGS twice
scripts: Fixed printf format mismatch
scripts/tags.sh: use `find` for $ALLSOURCE_ARCHS generation
coccinelle: deref_null: improve performance
coccinelle: mini_lock: improve performance
powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
kbuild: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selectable if enabled
kbuild: LD_DEAD_CODE_DATA_ELIMINATION no -ffunction-sections/-fdata-sections for module build
kbuild: Fix asm-generic/vmlinux.lds.h for LD_DEAD_CODE_DATA_ELIMINATION
modpost: constify *modname function argument where possible
modpost: remove redundant is_vmlinux() test
modpost: use strstarts() helper more widely
modpost: pass struct elf_info pointer to get_modinfo()
checkpatch: remove VMLINUX_SYMBOL() check
vmlinux.lds.h: remove no-op macro VMLINUX_SYMBOL()
kbuild: remove CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX
export.h: remove code for prefixing symbols with underscore
depmod.sh: remove symbol prefix support
...
Diffstat (limited to 'scripts/mod')
-rw-r--r-- | scripts/mod/modpost.c | 97 |
1 files changed, 41 insertions, 56 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 4ff08a0ef5d3..1663fb19343a 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -19,9 +19,7 @@ | |||
19 | #include <stdbool.h> | 19 | #include <stdbool.h> |
20 | #include <errno.h> | 20 | #include <errno.h> |
21 | #include "modpost.h" | 21 | #include "modpost.h" |
22 | #include "../../include/generated/autoconf.h" | ||
23 | #include "../../include/linux/license.h" | 22 | #include "../../include/linux/license.h" |
24 | #include "../../include/linux/export.h" | ||
25 | 23 | ||
26 | /* Are we using CONFIG_MODVERSIONS? */ | 24 | /* Are we using CONFIG_MODVERSIONS? */ |
27 | static int modversions = 0; | 25 | static int modversions = 0; |
@@ -123,7 +121,7 @@ void *do_nofail(void *ptr, const char *expr) | |||
123 | /* A list of all modules we processed */ | 121 | /* A list of all modules we processed */ |
124 | static struct module *modules; | 122 | static struct module *modules; |
125 | 123 | ||
126 | static struct module *find_module(char *modname) | 124 | static struct module *find_module(const char *modname) |
127 | { | 125 | { |
128 | struct module *mod; | 126 | struct module *mod; |
129 | 127 | ||
@@ -591,35 +589,32 @@ static void parse_elf_finish(struct elf_info *info) | |||
591 | static int ignore_undef_symbol(struct elf_info *info, const char *symname) | 589 | static int ignore_undef_symbol(struct elf_info *info, const char *symname) |
592 | { | 590 | { |
593 | /* ignore __this_module, it will be resolved shortly */ | 591 | /* ignore __this_module, it will be resolved shortly */ |
594 | if (strcmp(symname, VMLINUX_SYMBOL_STR(__this_module)) == 0) | 592 | if (strcmp(symname, "__this_module") == 0) |
595 | return 1; | 593 | return 1; |
596 | /* ignore global offset table */ | 594 | /* ignore global offset table */ |
597 | if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0) | 595 | if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0) |
598 | return 1; | 596 | return 1; |
599 | if (info->hdr->e_machine == EM_PPC) | 597 | if (info->hdr->e_machine == EM_PPC) |
600 | /* 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 */ |
601 | if (strncmp(symname, "_restgpr_", sizeof("_restgpr_") - 1) == 0 || | 599 | if (strstarts(symname, "_restgpr_") || |
602 | strncmp(symname, "_savegpr_", sizeof("_savegpr_") - 1) == 0 || | 600 | strstarts(symname, "_savegpr_") || |
603 | strncmp(symname, "_rest32gpr_", sizeof("_rest32gpr_") - 1) == 0 || | 601 | strstarts(symname, "_rest32gpr_") || |
604 | strncmp(symname, "_save32gpr_", sizeof("_save32gpr_") - 1) == 0 || | 602 | strstarts(symname, "_save32gpr_") || |
605 | strncmp(symname, "_restvr_", sizeof("_restvr_") - 1) == 0 || | 603 | strstarts(symname, "_restvr_") || |
606 | strncmp(symname, "_savevr_", sizeof("_savevr_") - 1) == 0) | 604 | strstarts(symname, "_savevr_")) |
607 | return 1; | 605 | return 1; |
608 | if (info->hdr->e_machine == EM_PPC64) | 606 | if (info->hdr->e_machine == EM_PPC64) |
609 | /* 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 */ |
610 | if (strncmp(symname, "_restgpr0_", sizeof("_restgpr0_") - 1) == 0 || | 608 | if (strstarts(symname, "_restgpr0_") || |
611 | strncmp(symname, "_savegpr0_", sizeof("_savegpr0_") - 1) == 0 || | 609 | strstarts(symname, "_savegpr0_") || |
612 | strncmp(symname, "_restvr_", sizeof("_restvr_") - 1) == 0 || | 610 | strstarts(symname, "_restvr_") || |
613 | strncmp(symname, "_savevr_", sizeof("_savevr_") - 1) == 0 || | 611 | strstarts(symname, "_savevr_") || |
614 | strcmp(symname, ".TOC.") == 0) | 612 | strcmp(symname, ".TOC.") == 0) |
615 | return 1; | 613 | return 1; |
616 | /* Do not ignore this symbol */ | 614 | /* Do not ignore this symbol */ |
617 | return 0; | 615 | return 0; |
618 | } | 616 | } |
619 | 617 | ||
620 | #define CRC_PFX VMLINUX_SYMBOL_STR(__crc_) | ||
621 | #define KSYMTAB_PFX VMLINUX_SYMBOL_STR(__ksymtab_) | ||
622 | |||
623 | static void handle_modversions(struct module *mod, struct elf_info *info, | 618 | static void handle_modversions(struct module *mod, struct elf_info *info, |
624 | Elf_Sym *sym, const char *symname) | 619 | Elf_Sym *sym, const char *symname) |
625 | { | 620 | { |
@@ -628,13 +623,13 @@ static void handle_modversions(struct module *mod, struct elf_info *info, | |||
628 | bool is_crc = false; | 623 | bool is_crc = false; |
629 | 624 | ||
630 | if ((!is_vmlinux(mod->name) || mod->is_dot_o) && | 625 | if ((!is_vmlinux(mod->name) || mod->is_dot_o) && |
631 | strncmp(symname, "__ksymtab", 9) == 0) | 626 | strstarts(symname, "__ksymtab")) |
632 | export = export_from_secname(info, get_secindex(info, sym)); | 627 | export = export_from_secname(info, get_secindex(info, sym)); |
633 | else | 628 | else |
634 | export = export_from_sec(info, get_secindex(info, sym)); | 629 | export = export_from_sec(info, get_secindex(info, sym)); |
635 | 630 | ||
636 | /* CRC'd symbol */ | 631 | /* CRC'd symbol */ |
637 | if (strncmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) { | 632 | if (strstarts(symname, "__crc_")) { |
638 | is_crc = true; | 633 | is_crc = true; |
639 | crc = (unsigned int) sym->st_value; | 634 | crc = (unsigned int) sym->st_value; |
640 | if (sym->st_shndx != SHN_UNDEF && sym->st_shndx != SHN_ABS) { | 635 | if (sym->st_shndx != SHN_UNDEF && sym->st_shndx != SHN_ABS) { |
@@ -647,13 +642,13 @@ static void handle_modversions(struct module *mod, struct elf_info *info, | |||
647 | info->sechdrs[sym->st_shndx].sh_addr : 0); | 642 | info->sechdrs[sym->st_shndx].sh_addr : 0); |
648 | crc = *crcp; | 643 | crc = *crcp; |
649 | } | 644 | } |
650 | sym_update_crc(symname + strlen(CRC_PFX), mod, crc, | 645 | sym_update_crc(symname + strlen("__crc_"), mod, crc, |
651 | export); | 646 | export); |
652 | } | 647 | } |
653 | 648 | ||
654 | switch (sym->st_shndx) { | 649 | switch (sym->st_shndx) { |
655 | case SHN_COMMON: | 650 | case SHN_COMMON: |
656 | if (!strncmp(symname, "__gnu_lto_", sizeof("__gnu_lto_")-1)) { | 651 | if (strstarts(symname, "__gnu_lto_")) { |
657 | /* Should warn here, but modpost runs before the linker */ | 652 | /* Should warn here, but modpost runs before the linker */ |
658 | } else | 653 | } else |
659 | warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name); | 654 | warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name); |
@@ -685,15 +680,10 @@ static void handle_modversions(struct module *mod, struct elf_info *info, | |||
685 | } | 680 | } |
686 | #endif | 681 | #endif |
687 | 682 | ||
688 | #ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX | ||
689 | if (symname[0] != '_') | ||
690 | break; | ||
691 | else | ||
692 | symname++; | ||
693 | #endif | ||
694 | if (is_crc) { | 683 | if (is_crc) { |
695 | const char *e = is_vmlinux(mod->name) ?"":".ko"; | 684 | const char *e = is_vmlinux(mod->name) ?"":".ko"; |
696 | warn("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n", symname + strlen(CRC_PFX), mod->name, e); | 685 | warn("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n", |
686 | symname + strlen("__crc_"), mod->name, e); | ||
697 | } | 687 | } |
698 | mod->unres = alloc_symbol(symname, | 688 | mod->unres = alloc_symbol(symname, |
699 | ELF_ST_BIND(sym->st_info) == STB_WEAK, | 689 | ELF_ST_BIND(sym->st_info) == STB_WEAK, |
@@ -701,13 +691,13 @@ static void handle_modversions(struct module *mod, struct elf_info *info, | |||
701 | break; | 691 | break; |
702 | default: | 692 | default: |
703 | /* All exported symbols */ | 693 | /* All exported symbols */ |
704 | if (strncmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) { | 694 | if (strstarts(symname, "__ksymtab_")) { |
705 | sym_add_exported(symname + strlen(KSYMTAB_PFX), mod, | 695 | sym_add_exported(symname + strlen("__ksymtab_"), mod, |
706 | export); | 696 | export); |
707 | } | 697 | } |
708 | if (strcmp(symname, VMLINUX_SYMBOL_STR(init_module)) == 0) | 698 | if (strcmp(symname, "init_module") == 0) |
709 | mod->has_init = 1; | 699 | mod->has_init = 1; |
710 | if (strcmp(symname, VMLINUX_SYMBOL_STR(cleanup_module)) == 0) | 700 | if (strcmp(symname, "cleanup_module") == 0) |
711 | mod->has_cleanup = 1; | 701 | mod->has_cleanup = 1; |
712 | break; | 702 | break; |
713 | } | 703 | } |
@@ -734,16 +724,17 @@ static char *next_string(char *string, unsigned long *secsize) | |||
734 | return string; | 724 | return string; |
735 | } | 725 | } |
736 | 726 | ||
737 | static char *get_next_modinfo(void *modinfo, unsigned long modinfo_len, | 727 | static char *get_next_modinfo(struct elf_info *info, const char *tag, |
738 | const char *tag, char *info) | 728 | char *prev) |
739 | { | 729 | { |
740 | char *p; | 730 | char *p; |
741 | unsigned int taglen = strlen(tag); | 731 | unsigned int taglen = strlen(tag); |
742 | unsigned long size = modinfo_len; | 732 | char *modinfo = info->modinfo; |
733 | unsigned long size = info->modinfo_len; | ||
743 | 734 | ||
744 | if (info) { | 735 | if (prev) { |
745 | size -= info - (char *)modinfo; | 736 | size -= prev - modinfo; |
746 | modinfo = next_string(info, &size); | 737 | modinfo = next_string(prev, &size); |
747 | } | 738 | } |
748 | 739 | ||
749 | for (p = modinfo; p; p = next_string(p, &size)) { | 740 | for (p = modinfo; p; p = next_string(p, &size)) { |
@@ -753,11 +744,10 @@ static char *get_next_modinfo(void *modinfo, unsigned long modinfo_len, | |||
753 | return NULL; | 744 | return NULL; |
754 | } | 745 | } |
755 | 746 | ||
756 | static char *get_modinfo(void *modinfo, unsigned long modinfo_len, | 747 | static char *get_modinfo(struct elf_info *info, const char *tag) |
757 | const char *tag) | ||
758 | 748 | ||
759 | { | 749 | { |
760 | return get_next_modinfo(modinfo, modinfo_len, tag, NULL); | 750 | return get_next_modinfo(info, tag, NULL); |
761 | } | 751 | } |
762 | 752 | ||
763 | /** | 753 | /** |
@@ -1181,13 +1171,13 @@ static int secref_whitelist(const struct sectioncheck *mismatch, | |||
1181 | /* Check for pattern 1 */ | 1171 | /* Check for pattern 1 */ |
1182 | if (match(tosec, init_data_sections) && | 1172 | if (match(tosec, init_data_sections) && |
1183 | match(fromsec, data_sections) && | 1173 | match(fromsec, data_sections) && |
1184 | (strncmp(fromsym, "__param", strlen("__param")) == 0)) | 1174 | strstarts(fromsym, "__param")) |
1185 | return 0; | 1175 | return 0; |
1186 | 1176 | ||
1187 | /* Check for pattern 1a */ | 1177 | /* Check for pattern 1a */ |
1188 | if (strcmp(tosec, ".init.text") == 0 && | 1178 | if (strcmp(tosec, ".init.text") == 0 && |
1189 | match(fromsec, data_sections) && | 1179 | match(fromsec, data_sections) && |
1190 | (strncmp(fromsym, "__param_ops_", strlen("__param_ops_")) == 0)) | 1180 | strstarts(fromsym, "__param_ops_")) |
1191 | return 0; | 1181 | return 0; |
1192 | 1182 | ||
1193 | /* Check for pattern 2 */ | 1183 | /* Check for pattern 2 */ |
@@ -1542,8 +1532,7 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf, | |||
1542 | from = find_elf_symbol2(elf, r->r_offset, fromsec); | 1532 | from = find_elf_symbol2(elf, r->r_offset, fromsec); |
1543 | fromsym = sym_name(elf, from); | 1533 | fromsym = sym_name(elf, from); |
1544 | 1534 | ||
1545 | if (!strncmp(fromsym, "reference___initcall", | 1535 | if (strstarts(fromsym, "reference___initcall")) |
1546 | sizeof("reference___initcall")-1)) | ||
1547 | return; | 1536 | return; |
1548 | 1537 | ||
1549 | tosec = sec_name(elf, get_secindex(elf, sym)); | 1538 | tosec = sec_name(elf, get_secindex(elf, sym)); |
@@ -1940,7 +1929,7 @@ static char *remove_dot(char *s) | |||
1940 | return s; | 1929 | return s; |
1941 | } | 1930 | } |
1942 | 1931 | ||
1943 | static void read_symbols(char *modname) | 1932 | static void read_symbols(const char *modname) |
1944 | { | 1933 | { |
1945 | const char *symname; | 1934 | const char *symname; |
1946 | char *version; | 1935 | char *version; |
@@ -1961,7 +1950,7 @@ static void read_symbols(char *modname) | |||
1961 | mod->skip = 1; | 1950 | mod->skip = 1; |
1962 | } | 1951 | } |
1963 | 1952 | ||
1964 | license = get_modinfo(info.modinfo, info.modinfo_len, "license"); | 1953 | license = get_modinfo(&info, "license"); |
1965 | if (!license && !is_vmlinux(modname)) | 1954 | if (!license && !is_vmlinux(modname)) |
1966 | warn("modpost: missing MODULE_LICENSE() in %s\n" | 1955 | warn("modpost: missing MODULE_LICENSE() in %s\n" |
1967 | "see include/linux/module.h for " | 1956 | "see include/linux/module.h for " |
@@ -1973,8 +1962,7 @@ static void read_symbols(char *modname) | |||
1973 | mod->gpl_compatible = 0; | 1962 | mod->gpl_compatible = 0; |
1974 | break; | 1963 | break; |
1975 | } | 1964 | } |
1976 | license = get_next_modinfo(info.modinfo, info.modinfo_len, | 1965 | license = get_next_modinfo(&info, "license", license); |
1977 | "license", license); | ||
1978 | } | 1966 | } |
1979 | 1967 | ||
1980 | for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { | 1968 | for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { |
@@ -1983,11 +1971,10 @@ static void read_symbols(char *modname) | |||
1983 | handle_modversions(mod, &info, sym, symname); | 1971 | handle_modversions(mod, &info, sym, symname); |
1984 | handle_moddevtable(mod, &info, sym, symname); | 1972 | handle_moddevtable(mod, &info, sym, symname); |
1985 | } | 1973 | } |
1986 | if (!is_vmlinux(modname) || | 1974 | if (!is_vmlinux(modname) || vmlinux_section_warnings) |
1987 | (is_vmlinux(modname) && vmlinux_section_warnings)) | ||
1988 | check_sec_ref(mod, modname, &info); | 1975 | check_sec_ref(mod, modname, &info); |
1989 | 1976 | ||
1990 | version = get_modinfo(info.modinfo, info.modinfo_len, "version"); | 1977 | version = get_modinfo(&info, "version"); |
1991 | if (version) | 1978 | if (version) |
1992 | maybe_frob_rcs_version(modname, version, info.modinfo, | 1979 | maybe_frob_rcs_version(modname, version, info.modinfo, |
1993 | version - (char *)info.hdr); | 1980 | version - (char *)info.hdr); |
@@ -2174,9 +2161,7 @@ static void add_retpoline(struct buffer *b) | |||
2174 | 2161 | ||
2175 | static void add_staging_flag(struct buffer *b, const char *name) | 2162 | static void add_staging_flag(struct buffer *b, const char *name) |
2176 | { | 2163 | { |
2177 | static const char *staging_dir = "drivers/staging"; | 2164 | if (strstarts(name, "drivers/staging")) |
2178 | |||
2179 | if (strncmp(staging_dir, name, strlen(staging_dir)) == 0) | ||
2180 | buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n"); | 2165 | buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n"); |
2181 | } | 2166 | } |
2182 | 2167 | ||
@@ -2230,7 +2215,7 @@ static int add_versions(struct buffer *b, struct module *mod) | |||
2230 | err = 1; | 2215 | err = 1; |
2231 | break; | 2216 | break; |
2232 | } | 2217 | } |
2233 | buf_printf(b, "\t{ %#8x, __VMLINUX_SYMBOL_STR(%s) },\n", | 2218 | buf_printf(b, "\t{ %#8x, \"%s\" },\n", |
2234 | s->crc, s->name); | 2219 | s->crc, s->name); |
2235 | } | 2220 | } |
2236 | 2221 | ||