diff options
Diffstat (limited to 'scripts/mod/modpost.c')
-rw-r--r-- | scripts/mod/modpost.c | 90 |
1 files changed, 37 insertions, 53 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 113dc77b9f60..8e5610d428c5 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -582,6 +582,12 @@ static int strrcmp(const char *s, const char *sub) | |||
582 | 582 | ||
583 | /** | 583 | /** |
584 | * Whitelist to allow certain references to pass with no warning. | 584 | * Whitelist to allow certain references to pass with no warning. |
585 | * | ||
586 | * Pattern 0: | ||
587 | * Do not warn if funtion/data are marked with __init_refok/__initdata_refok. | ||
588 | * The pattern is identified by: | ||
589 | * fromsec = .text.init.refok | .data.init.refok | ||
590 | * | ||
585 | * Pattern 1: | 591 | * Pattern 1: |
586 | * If a module parameter is declared __initdata and permissions=0 | 592 | * If a module parameter is declared __initdata and permissions=0 |
587 | * then this is legal despite the warning generated. | 593 | * then this is legal despite the warning generated. |
@@ -619,14 +625,6 @@ static int strrcmp(const char *s, const char *sub) | |||
619 | * This pattern is identified by | 625 | * This pattern is identified by |
620 | * refsymname = __init_begin, _sinittext, _einittext | 626 | * refsymname = __init_begin, _sinittext, _einittext |
621 | * | 627 | * |
622 | * Pattern 6: | ||
623 | * During the early init phase we have references from .init.text to | ||
624 | * .text we have an intended section mismatch - do not warn about it. | ||
625 | * See kernel_init() in init/main.c | ||
626 | * tosec = .init.text | ||
627 | * fromsec = .text | ||
628 | * atsym = kernel_init | ||
629 | * | ||
630 | * Pattern 7: | 628 | * Pattern 7: |
631 | * Logos used in drivers/video/logo reside in __initdata but the | 629 | * Logos used in drivers/video/logo reside in __initdata but the |
632 | * funtion that references them are EXPORT_SYMBOL() so cannot be | 630 | * funtion that references them are EXPORT_SYMBOL() so cannot be |
@@ -642,16 +640,11 @@ static int strrcmp(const char *s, const char *sub) | |||
642 | * tosec = .init.text | 640 | * tosec = .init.text |
643 | * fromsec = .paravirtprobe | 641 | * fromsec = .paravirtprobe |
644 | * | 642 | * |
645 | * Pattern 9: | ||
646 | * Some of functions are common code between boot time and hotplug | ||
647 | * time. The bootmem allocater is called only boot time in its | ||
648 | * functions. So it's ok to reference. | ||
649 | * tosec = .init.text | ||
650 | * | ||
651 | * Pattern 10: | 643 | * Pattern 10: |
652 | * ia64 has machvec table for each platform. It is mixture of function | 644 | * ia64 has machvec table for each platform and |
653 | * pointer of .init.text and .text. | 645 | * powerpc has a machine desc table for each platform. |
654 | * fromsec = .machvec | 646 | * It is mixture of function pointers of .init.text and .text. |
647 | * fromsec = .machvec | .machine.desc | ||
655 | **/ | 648 | **/ |
656 | static int secref_whitelist(const char *modname, const char *tosec, | 649 | static int secref_whitelist(const char *modname, const char *tosec, |
657 | const char *fromsec, const char *atsym, | 650 | const char *fromsec, const char *atsym, |
@@ -678,11 +671,10 @@ static int secref_whitelist(const char *modname, const char *tosec, | |||
678 | NULL | 671 | NULL |
679 | }; | 672 | }; |
680 | 673 | ||
681 | const char *pat4sym[] = { | 674 | /* Check for pattern 0 */ |
682 | "sparse_index_alloc", | 675 | if ((strcmp(fromsec, ".text.init.refok") == 0) || |
683 | "zone_wait_table_init", | 676 | (strcmp(fromsec, ".data.init.refok") == 0)) |
684 | NULL | 677 | return 1; |
685 | }; | ||
686 | 678 | ||
687 | /* Check for pattern 1 */ | 679 | /* Check for pattern 1 */ |
688 | if (strcmp(tosec, ".init.data") != 0) | 680 | if (strcmp(tosec, ".init.data") != 0) |
@@ -725,12 +717,6 @@ static int secref_whitelist(const char *modname, const char *tosec, | |||
725 | if (strcmp(refsymname, *s) == 0) | 717 | if (strcmp(refsymname, *s) == 0) |
726 | return 1; | 718 | return 1; |
727 | 719 | ||
728 | /* Check for pattern 6 */ | ||
729 | if ((strcmp(tosec, ".init.text") == 0) && | ||
730 | (strcmp(fromsec, ".text") == 0) && | ||
731 | (strcmp(refsymname, "kernel_init") == 0)) | ||
732 | return 1; | ||
733 | |||
734 | /* Check for pattern 7 */ | 720 | /* Check for pattern 7 */ |
735 | if ((strcmp(tosec, ".init.data") == 0) && | 721 | if ((strcmp(tosec, ".init.data") == 0) && |
736 | (strncmp(fromsec, ".text", strlen(".text")) == 0) && | 722 | (strncmp(fromsec, ".text", strlen(".text")) == 0) && |
@@ -742,15 +728,9 @@ static int secref_whitelist(const char *modname, const char *tosec, | |||
742 | (strcmp(fromsec, ".paravirtprobe") == 0)) | 728 | (strcmp(fromsec, ".paravirtprobe") == 0)) |
743 | return 1; | 729 | return 1; |
744 | 730 | ||
745 | /* Check for pattern 9 */ | ||
746 | if ((strcmp(tosec, ".init.text") == 0) && | ||
747 | (strcmp(fromsec, ".text") == 0)) | ||
748 | for (s = pat4sym; *s; s++) | ||
749 | if (strcmp(atsym, *s) == 0) | ||
750 | return 1; | ||
751 | |||
752 | /* Check for pattern 10 */ | 731 | /* Check for pattern 10 */ |
753 | if (strcmp(fromsec, ".machvec") == 0) | 732 | if ((strcmp(fromsec, ".machvec") == 0) || |
733 | (strcmp(fromsec, ".machine.desc") == 0)) | ||
754 | return 1; | 734 | return 1; |
755 | 735 | ||
756 | return 0; | 736 | return 0; |
@@ -884,30 +864,34 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, | |||
884 | elf->strtab + before->st_name, refsymname)) | 864 | elf->strtab + before->st_name, refsymname)) |
885 | return; | 865 | return; |
886 | 866 | ||
867 | /* fromsec whitelist - without a valid 'before' | ||
868 | * powerpc has a GOT table in .got2 section */ | ||
869 | if (strcmp(fromsec, ".got2") == 0) | ||
870 | return; | ||
871 | |||
887 | if (before && after) { | 872 | if (before && after) { |
888 | warn("%s - Section mismatch: reference to %s:%s from %s " | 873 | warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s " |
889 | "between '%s' (at offset 0x%llx) and '%s'\n", | 874 | "(between '%s' and '%s')\n", |
890 | modname, secname, refsymname, fromsec, | 875 | modname, fromsec, (unsigned long long)r.r_offset, |
876 | secname, refsymname, | ||
891 | elf->strtab + before->st_name, | 877 | elf->strtab + before->st_name, |
892 | (long long)r.r_offset, | ||
893 | elf->strtab + after->st_name); | 878 | elf->strtab + after->st_name); |
894 | } else if (before) { | 879 | } else if (before) { |
895 | warn("%s - Section mismatch: reference to %s:%s from %s " | 880 | warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s " |
896 | "after '%s' (at offset 0x%llx)\n", | 881 | "(after '%s')\n", |
897 | modname, secname, refsymname, fromsec, | 882 | modname, fromsec, (unsigned long long)r.r_offset, |
898 | elf->strtab + before->st_name, | 883 | secname, refsymname, |
899 | (long long)r.r_offset); | 884 | elf->strtab + before->st_name); |
900 | } else if (after) { | 885 | } else if (after) { |
901 | warn("%s - Section mismatch: reference to %s:%s from %s " | 886 | warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s " |
902 | "before '%s' (at offset -0x%llx)\n", | 887 | "before '%s' (at offset -0x%llx)\n", |
903 | modname, secname, refsymname, fromsec, | 888 | modname, fromsec, (unsigned long long)r.r_offset, |
904 | elf->strtab + after->st_name, | 889 | secname, refsymname, |
905 | (long long)r.r_offset); | 890 | elf->strtab + after->st_name); |
906 | } else { | 891 | } else { |
907 | warn("%s - Section mismatch: reference to %s:%s from %s " | 892 | warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s\n", |
908 | "(offset 0x%llx)\n", | 893 | modname, fromsec, (unsigned long long)r.r_offset, |
909 | modname, secname, fromsec, refsymname, | 894 | secname, refsymname); |
910 | (long long)r.r_offset); | ||
911 | } | 895 | } |
912 | } | 896 | } |
913 | 897 | ||