Skip to content

Commit a0d8f80

Browse files
Villemoesrustyrussell
authored andcommitted
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 <[email protected]> Signed-off-by: Rusty Russell <[email protected]>
1 parent fcd38ed commit a0d8f80

File tree

1 file changed

+10
-39
lines changed

1 file changed

+10
-39
lines changed

scripts/mod/modpost.c

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -772,32 +772,10 @@ static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr)
772772
sechdr->sh_name;
773773
}
774774

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-
*/
779-
static 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-
793775
/* The pattern is an array of simple patterns.
794776
* "foo" will match an exact string equal to "foo"
795777
* "*foo" will match a string that ends with "foo"
796778
* "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.
801779
*/
802780
static int match(const char *sym, const char * const pat[])
803781
{
@@ -816,13 +794,6 @@ static int match(const char *sym, const char * const pat[])
816794
if (strncmp(sym, p, strlen(p) - 1) == 0)
817795
return 1;
818796
}
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-
}
826797
/* no wildcards */
827798
else {
828799
if (strcmp(p, sym) == 0)
@@ -880,29 +851,29 @@ static void check_section(const char *modname, struct elf_info *elf,
880851

881852

882853
#define ALL_INIT_DATA_SECTIONS \
883-
".init.setup$", ".init.rodata$", ".meminit.rodata$", \
884-
".init.data$", ".meminit.data$"
854+
".init.setup", ".init.rodata", ".meminit.rodata", \
855+
".init.data", ".meminit.data"
885856
#define ALL_EXIT_DATA_SECTIONS \
886-
".exit.data$", ".memexit.data$"
857+
".exit.data", ".memexit.data"
887858

888859
#define ALL_INIT_TEXT_SECTIONS \
889-
".init.text$", ".meminit.text$"
860+
".init.text", ".meminit.text"
890861
#define ALL_EXIT_TEXT_SECTIONS \
891-
".exit.text$", ".memexit.text$"
862+
".exit.text", ".memexit.text"
892863

893864
#define ALL_PCI_INIT_SECTIONS \
894-
".pci_fixup_early$", ".pci_fixup_header$", ".pci_fixup_final$", \
895-
".pci_fixup_enable$", ".pci_fixup_resume$", \
896-
".pci_fixup_resume_early$", ".pci_fixup_suspend$"
865+
".pci_fixup_early", ".pci_fixup_header", ".pci_fixup_final", \
866+
".pci_fixup_enable", ".pci_fixup_resume", \
867+
".pci_fixup_resume_early", ".pci_fixup_suspend"
897868

898869
#define ALL_XXXINIT_SECTIONS MEM_INIT_SECTIONS
899870
#define ALL_XXXEXIT_SECTIONS MEM_EXIT_SECTIONS
900871

901872
#define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS
902873
#define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS
903874

904-
#define DATA_SECTIONS ".data$", ".data.rel$"
905-
#define TEXT_SECTIONS ".text$", ".text.unlikely$"
875+
#define DATA_SECTIONS ".data", ".data.rel"
876+
#define TEXT_SECTIONS ".text", ".text.unlikely"
906877

907878
#define INIT_SECTIONS ".init.*"
908879
#define MEM_INIT_SECTIONS ".meminit.*"

0 commit comments

Comments
 (0)