linux-stable/scripts/mod
Masahiro Yamada b1205cc72b modpost: fix section mismatch message for RELA
[ Upstream commit 1c4a7587d1 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-12-13 18:44:59 +01:00
..
.gitignore .gitignore: prefix local generated files with a slash 2021-05-02 00:43:35 +09:00
devicetable-offsets.c vfio/cdx: add support for CDX bus 2023-06-16 12:27:04 -06:00
empty.c
file2alias.c modpost: fix ishtp MODULE_DEVICE_TABLE built on big-endian host 2023-11-20 11:59:28 +01:00
list.h modpost: import include/linux/list.h 2022-05-08 03:17:00 +09:00
Makefile scripts/mod: disable LTO for empty.c 2021-01-14 08:21:09 -08: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-12-13 18:44:59 +01:00
modpost.h modpost: clean up MIPS64 little endian relocation code 2023-07-31 23:42:14 +09:00
sumversion.c modpost: fix array_size.cocci warning 2022-11-21 10:18:39 +09:00