diff options
Diffstat (limited to 'scripts/mod/modpost.c')
| -rw-r--r-- | scripts/mod/modpost.c | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 569e68410d7a..65bdfdb56877 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
| @@ -686,6 +686,30 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf_Addr addr, | |||
| 686 | return NULL; | 686 | return NULL; |
| 687 | } | 687 | } |
| 688 | 688 | ||
| 689 | static inline int is_arm_mapping_symbol(const char *str) | ||
| 690 | { | ||
| 691 | return str[0] == '$' && strchr("atd", str[1]) | ||
| 692 | && (str[2] == '\0' || str[2] == '.'); | ||
| 693 | } | ||
| 694 | |||
| 695 | /* | ||
| 696 | * If there's no name there, ignore it; likewise, ignore it if it's | ||
| 697 | * one of the magic symbols emitted used by current ARM tools. | ||
| 698 | * | ||
| 699 | * Otherwise if find_symbols_between() returns those symbols, they'll | ||
| 700 | * fail the whitelist tests and cause lots of false alarms ... fixable | ||
| 701 | * only by merging __exit and __init sections into __text, bloating | ||
| 702 | * the kernel (which is especially evil on embedded platforms). | ||
| 703 | */ | ||
| 704 | static inline int is_valid_name(struct elf_info *elf, Elf_Sym *sym) | ||
| 705 | { | ||
| 706 | const char *name = elf->strtab + sym->st_name; | ||
| 707 | |||
| 708 | if (!name || !strlen(name)) | ||
| 709 | return 0; | ||
| 710 | return !is_arm_mapping_symbol(name); | ||
| 711 | } | ||
| 712 | |||
| 689 | /* | 713 | /* |
| 690 | * Find symbols before or equal addr and after addr - in the section sec. | 714 | * Find symbols before or equal addr and after addr - in the section sec. |
| 691 | * If we find two symbols with equal offset prefer one with a valid name. | 715 | * If we find two symbols with equal offset prefer one with a valid name. |
| @@ -714,16 +738,15 @@ static void find_symbols_between(struct elf_info *elf, Elf_Addr addr, | |||
| 714 | symsec = secstrings + elf->sechdrs[sym->st_shndx].sh_name; | 738 | symsec = secstrings + elf->sechdrs[sym->st_shndx].sh_name; |
| 715 | if (strcmp(symsec, sec) != 0) | 739 | if (strcmp(symsec, sec) != 0) |
| 716 | continue; | 740 | continue; |
| 741 | if (!is_valid_name(elf, sym)) | ||
| 742 | continue; | ||
| 717 | if (sym->st_value <= addr) { | 743 | if (sym->st_value <= addr) { |
| 718 | if ((addr - sym->st_value) < beforediff) { | 744 | if ((addr - sym->st_value) < beforediff) { |
| 719 | beforediff = addr - sym->st_value; | 745 | beforediff = addr - sym->st_value; |
| 720 | *before = sym; | 746 | *before = sym; |
| 721 | } | 747 | } |
| 722 | else if ((addr - sym->st_value) == beforediff) { | 748 | else if ((addr - sym->st_value) == beforediff) { |
| 723 | /* equal offset, valid name? */ | 749 | *before = sym; |
| 724 | const char *name = elf->strtab + sym->st_name; | ||
| 725 | if (name && strlen(name)) | ||
| 726 | *before = sym; | ||
| 727 | } | 750 | } |
| 728 | } | 751 | } |
| 729 | else | 752 | else |
| @@ -733,10 +756,7 @@ static void find_symbols_between(struct elf_info *elf, Elf_Addr addr, | |||
| 733 | *after = sym; | 756 | *after = sym; |
| 734 | } | 757 | } |
| 735 | else if ((sym->st_value - addr) == afterdiff) { | 758 | else if ((sym->st_value - addr) == afterdiff) { |
| 736 | /* equal offset, valid name? */ | 759 | *after = sym; |
| 737 | const char *name = elf->strtab + sym->st_name; | ||
| 738 | if (name && strlen(name)) | ||
| 739 | *after = sym; | ||
| 740 | } | 760 | } |
| 741 | } | 761 | } |
| 742 | } | 762 | } |
| @@ -941,7 +961,7 @@ static int init_section_ref_ok(const char *name) | |||
| 941 | ".opd", /* see comment [OPD] at exit_section_ref_ok() */ | 961 | ".opd", /* see comment [OPD] at exit_section_ref_ok() */ |
| 942 | ".toc1", /* used by ppc64 */ | 962 | ".toc1", /* used by ppc64 */ |
| 943 | ".stab", | 963 | ".stab", |
| 944 | ".rodata", | 964 | ".data.rel.ro", /* used by parisc64 */ |
| 945 | ".parainstructions", | 965 | ".parainstructions", |
| 946 | ".text.lock", | 966 | ".text.lock", |
| 947 | "__bug_table", /* used by powerpc for BUG() */ | 967 | "__bug_table", /* used by powerpc for BUG() */ |
| @@ -964,6 +984,7 @@ static int init_section_ref_ok(const char *name) | |||
| 964 | ".eh_frame", | 984 | ".eh_frame", |
| 965 | ".debug", | 985 | ".debug", |
| 966 | ".parainstructions", | 986 | ".parainstructions", |
| 987 | ".rodata", | ||
| 967 | NULL | 988 | NULL |
| 968 | }; | 989 | }; |
| 969 | /* part of section name */ | 990 | /* part of section name */ |
