aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorRasmus Villemoes <linux@rasmusvillemoes.dk>2014-07-26 17:58:01 -0400
committerRusty Russell <rusty@rustcorp.com.au>2014-07-27 07:22:46 -0400
commita0d8f8037468a3b5f964417f71853ccf301b9f39 (patch)
treec85a06971f7283667825dd71463e36d5a0472e0c /scripts
parentfcd38ed0ff263156c3917c70c2fb0b7e91bfeab1 (diff)
scripts: modpost: Remove numeric suffix pattern matching
For several years, the pattern "foo$" has effectively been treated as equivalent to "foo" due to a bug in the (misnamed) helper number_prefix(). This hasn't been observed to cause any problems, so remove the broken $ functionality and change all foo$ patterns to foo. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/mod/modpost.c49
1 files changed, 10 insertions, 39 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 5ba203b9eddf..091d90573b63 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -772,32 +772,10 @@ static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr)
772 sechdr->sh_name; 772 sechdr->sh_name;
773} 773}
774 774
775/* if sym is empty or point to a string
776 * like ".[0-9]+" then return 1.
777 * This is the optional prefix added by ld to some sections
778 */
779static int number_prefix(const char *sym)
780{
781 if (*sym++ == '\0')
782 return 1;
783 if (*sym != '.')
784 return 0;
785 do {
786 char c = *sym++;
787 if (c < '0' || c > '9')
788 return 0;
789 } while (*sym);
790 return 1;
791}
792
793/* The pattern is an array of simple patterns. 775/* The pattern is an array of simple patterns.
794 * "foo" will match an exact string equal to "foo" 776 * "foo" will match an exact string equal to "foo"
795 * "*foo" will match a string that ends with "foo" 777 * "*foo" will match a string that ends with "foo"
796 * "foo*" will match a string that begins with "foo" 778 * "foo*" will match a string that begins with "foo"
797 * "foo$" will match a string equal to "foo" or "foo.1"
798 * where the '1' can be any number including several digits.
799 * The $ syntax is for sections where ld append a dot number
800 * to make section name unique.
801 */ 779 */
802static int match(const char *sym, const char * const pat[]) 780static int match(const char *sym, const char * const pat[])
803{ 781{
@@ -816,13 +794,6 @@ static int match(const char *sym, const char * const pat[])
816 if (strncmp(sym, p, strlen(p) - 1) == 0) 794 if (strncmp(sym, p, strlen(p) - 1) == 0)
817 return 1; 795 return 1;
818 } 796 }
819 /* "foo$" */
820 else if (*endp == '$') {
821 if (strncmp(sym, p, strlen(p) - 1) == 0) {
822 if (number_prefix(sym + strlen(p) - 1))
823 return 1;
824 }
825 }
826 /* no wildcards */ 797 /* no wildcards */
827 else { 798 else {
828 if (strcmp(p, sym) == 0) 799 if (strcmp(p, sym) == 0)
@@ -880,20 +851,20 @@ static void check_section(const char *modname, struct elf_info *elf,
880 851
881 852
882#define ALL_INIT_DATA_SECTIONS \ 853#define ALL_INIT_DATA_SECTIONS \
883 ".init.setup$", ".init.rodata$", ".meminit.rodata$", \ 854 ".init.setup", ".init.rodata", ".meminit.rodata", \
884 ".init.data$", ".meminit.data$" 855 ".init.data", ".meminit.data"
885#define ALL_EXIT_DATA_SECTIONS \ 856#define ALL_EXIT_DATA_SECTIONS \
886 ".exit.data$", ".memexit.data$" 857 ".exit.data", ".memexit.data"
887 858
888#define ALL_INIT_TEXT_SECTIONS \ 859#define ALL_INIT_TEXT_SECTIONS \
889 ".init.text$", ".meminit.text$" 860 ".init.text", ".meminit.text"
890#define ALL_EXIT_TEXT_SECTIONS \ 861#define ALL_EXIT_TEXT_SECTIONS \
891 ".exit.text$", ".memexit.text$" 862 ".exit.text", ".memexit.text"
892 863
893#define ALL_PCI_INIT_SECTIONS \ 864#define ALL_PCI_INIT_SECTIONS \
894 ".pci_fixup_early$", ".pci_fixup_header$", ".pci_fixup_final$", \ 865 ".pci_fixup_early", ".pci_fixup_header", ".pci_fixup_final", \
895 ".pci_fixup_enable$", ".pci_fixup_resume$", \ 866 ".pci_fixup_enable", ".pci_fixup_resume", \
896 ".pci_fixup_resume_early$", ".pci_fixup_suspend$" 867 ".pci_fixup_resume_early", ".pci_fixup_suspend"
897 868
898#define ALL_XXXINIT_SECTIONS MEM_INIT_SECTIONS 869#define ALL_XXXINIT_SECTIONS MEM_INIT_SECTIONS
899#define ALL_XXXEXIT_SECTIONS MEM_EXIT_SECTIONS 870#define ALL_XXXEXIT_SECTIONS MEM_EXIT_SECTIONS
@@ -901,8 +872,8 @@ static void check_section(const char *modname, struct elf_info *elf,
901#define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS 872#define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS
902#define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS 873#define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS
903 874
904#define DATA_SECTIONS ".data$", ".data.rel$" 875#define DATA_SECTIONS ".data", ".data.rel"
905#define TEXT_SECTIONS ".text$", ".text.unlikely$" 876#define TEXT_SECTIONS ".text", ".text.unlikely"
906 877
907#define INIT_SECTIONS ".init.*" 878#define INIT_SECTIONS ".init.*"
908#define MEM_INIT_SECTIONS ".meminit.*" 879#define MEM_INIT_SECTIONS ".meminit.*"