Files
linux-cix/scripts/mod
Masahiro Yamada 507f02bf2f modpost: fix section mismatch message for RELA
Mainline: 1c4a7587d1bbee0fd53b63af60e4244a62775f57
From: v6.7-rc2
Severity: Moderate

task: 189525

[ Upstream commit 1c4a7587d1bbee0fd53b63af60e4244a62775f57 ]

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>

(backported from commit b1205cc72b)

K2CI-Arch: None
Signed-off-by: k2ci <kernel-bot@kylinos.cn>
Change-Id: Iff7ddefdb70bc259c78766ac0b1a582e9df96876
Reviewed-on: http://gerrit.kylin.com/c/klinux/+/88319
Reviewed-by: Jackie Liu <liuyun01@kylinos.cn>
2023-12-25 09:37:51 +08:00
..