• Masahiro Yamada's avatar
    modpost: fix section mismatch message for RELA · 1c4a7587
    Masahiro Yamada authored
    The section mismatch check prints a bogus symbol name on some
    architectures.
    
    [test code]
    
      #include <linux/init.h>
    
      int __initdata foo;
      int get_foo(void) { return foo; }
    
    If you compile it with GCC for riscv or loongarch, modpost will show an
    incorrect symbol name:
    
      WARNING: modpost: vmlinux: section mismatch in reference: get_foo+0x8 (section: .text) -> done (section: .init.data)
    
    To get the correct symbol address, the st_value must be added.
    
    This issue has never been noticed since commit 93684d3b ("kbuild:
    include symbol names in section mismatch warnings") presumably because
    st_value becomes zero on most architectures when the referenced symbol
    is looked up. It is not true for riscv or loongarch, at least.
    
    With this fix, modpost will show the correct symbol name:
    
      WARNING: modpost: vmlinux: section mismatch in reference: get_foo+0x8 (section: .text) -> foo (section: .init.data)
    Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
    Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
    1c4a7587
modpost.c 56.6 KB