Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

[PATCH] remove modpost false warnings on ARM

This patch stops "modpost" from issuing erroneous modpost warnings on ARM
builds, which it's been doing since since maybe last summer. A canonical
example would be driver method table entries:

WARNING: <path> - Section mismatch: reference to .exit.text:<name>_remove
from .data after '$d' (at offset 0x4)

That "$d" symbol is generated by tools conformant with ARM ABI specs; in
this case it's a symbol **in the middle of** a "<name>_driver" struct.

The erroneous warnings appear to be issued because "modpost" whitelists
references from "<name>_driver" data into init and exit sections ... but
doesn't know should also include those "$d" mapping symbols, which are not
otherwise associated with "<name>_driver" symbols.

This patch prevents the modpost symbol lookup code from ever returning
those mapping symbols, so it will return a whitelisted symbol instead.
Then things work as expected.

Now to revert various code-bloating "fixes" that got merged because of this
modpost bug....

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Roman Zippel <zippel@linux-m68k.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

David Brownell and committed by
Linus Torvalds
da68d61f 3deac046

+28 -8
+28 -8
scripts/mod/modpost.c
··· 686 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 714 * Find symbols before or equal addr and after addr - in the section sec. 691 715 * If we find two symbols with equal offset prefer one with a valid name. ··· 738 714 symsec = secstrings + elf->sechdrs[sym->st_shndx].sh_name; 739 715 if (strcmp(symsec, sec) != 0) 740 716 continue; 717 + if (!is_valid_name(elf, sym)) 718 + continue; 741 719 if (sym->st_value <= addr) { 742 720 if ((addr - sym->st_value) < beforediff) { 743 721 beforediff = addr - sym->st_value; 744 722 *before = sym; 745 723 } 746 724 else if ((addr - sym->st_value) == beforediff) { 747 - /* equal offset, valid name? */ 748 - const char *name = elf->strtab + sym->st_name; 749 - if (name && strlen(name)) 750 - *before = sym; 725 + *before = sym; 751 726 } 752 727 } 753 728 else ··· 756 733 *after = sym; 757 734 } 758 735 else if ((sym->st_value - addr) == afterdiff) { 759 - /* equal offset, valid name? */ 760 - const char *name = elf->strtab + sym->st_name; 761 - if (name && strlen(name)) 762 - *after = sym; 736 + *after = sym; 763 737 } 764 738 } 765 739 }