• Masahiro Yamada's avatar
    export.h, genksyms: do not make genksyms calculate CRC of trimmed symbols · 69a94abb
    Masahiro Yamada authored
    Arnd Bergmann reported false-positive modpost warnings detected by his
    randconfig testing of linux-next.
    
    Actually, this happens under the combination of CONFIG_MODVERSIONS
    and CONFIG_TRIM_UNUSED_KSYMS since commit 15bfc234 ("modpost:
    check for static EXPORT_SYMBOL* functions").
    
    For example, arch/arm/config/multi_v7_defconfig + CONFIG_MODVERSIONS
    + CONFIG_TRIM_UNUSED_KSYMS produces the following false-positives:
    
    WARNING: "__lshrdi3" [vmlinux] is a static (unknown)
    WARNING: "__ashrdi3" [vmlinux] is a static (unknown)
    WARNING: "__aeabi_lasr" [vmlinux] is a static (unknown)
    WARNING: "__aeabi_llsr" [vmlinux] is a static (unknown)
    WARNING: "ftrace_set_clr_event" [vmlinux] is a static (unknown)
    WARNING: "__muldi3" [vmlinux] is a static (unknown)
    WARNING: "__aeabi_ulcmp" [vmlinux] is a static (unknown)
    WARNING: "__ucmpdi2" [vmlinux] is a static (unknown)
    WARNING: "__aeabi_lmul" [vmlinux] is a static (unknown)
    WARNING: "__bswapsi2" [vmlinux] is a static (unknown)
    WARNING: "__bswapdi2" [vmlinux] is a static (unknown)
    WARNING: "__ashldi3" [vmlinux] is a static (unknown)
    WARNING: "__aeabi_llsl" [vmlinux] is a static (unknown)
    
    The root cause of the problem is not in the modpost, but in the
    implementation of CONFIG_TRIM_UNUSED_KSYMS.
    
    If there is at least one untrimmed symbol in the file, genksyms is
    invoked to calculate CRC of *all* the exported symbols in that file
    even if some of them have been trimmed due to no caller existing.
    
    As a result, .tmp_*.ver files contain CRC of trimmed symbols, thus
    unneeded, orphan __crc* symbols are added to objects. It had been
    harmless until recently.
    
    With commit 15bfc234 ("modpost: check for static EXPORT_SYMBOL*
    functions"), it is now harmful because the bogus __crc* symbols make
    modpost call sym_update_crc() to add the symbols to the hash table,
    but there is no one that clears the ->is_static member.
    
    I gave Fixes to the first commit that uncovered the issue, but the
    potential problem has long existed since commit f2355416
    ("export.h: allow for per-symbol configurable EXPORT_SYMBOL()").
    
    Fixes: 15bfc234 ("modpost: check for static EXPORT_SYMBOL* functions")
    Reported-by: default avatarArnd Bergmann <arnd@arndb.de>
    Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
    Tested-by: default avatarArnd Bergmann <arnd@arndb.de>
    69a94abb
keywords.c 2.1 KB