linux/scripts/mod
Masahiro Yamada 1c4a7587d1 modpost: fix section mismatch message for RELA
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 93684d3b80 ("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: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
2023-11-16 20:14:44 +09:00
..
.gitignore .gitignore: prefix local generated files with a slash 2021-05-02 00:43:35 +09:00
devicetable-offsets.c Staging driver updates for 6.7-rc1 2023-11-03 15:31:04 -10:00
empty.c
file2alias.c Kbuild updates for v6.7 2023-11-04 08:07:19 -10:00
list.h modpost: import include/linux/list.h 2022-05-08 03:17:00 +09:00
Makefile modpost: Optimize symbol search from linear to binary search 2023-10-03 20:25:59 +09:00
mk_elfconfig.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
modpost.c modpost: fix section mismatch message for RELA 2023-11-16 20:14:44 +09:00
modpost.h Kbuild updates for v6.7 2023-11-04 08:07:19 -10:00
sumversion.c modpost: fix array_size.cocci warning 2022-11-21 10:18:39 +09:00
symsearch.c modpost: Optimize symbol search from linear to binary search 2023-10-03 20:25:59 +09:00