scripts/kallsyms: fix offset overflow of kallsyms_relative_base
authorMasahiro Yamada <masahiroy@kernel.org>
Mon, 9 Dec 2019 03:51:48 +0000 (12:51 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Sat, 14 Dec 2019 06:53:04 +0000 (15:53 +0900)
commitfd2ab2f6610b2bec70e626c38de8a4242fa88e48
tree63ef989fe5aebaf326f916db8535dcb3683209ef
parentc8f3dea90e38194dae542c5d56e05d30447e58cb
scripts/kallsyms: fix offset overflow of kallsyms_relative_base

Since commit 5e5c4fa78745 ("scripts/kallsyms: shrink table before
sorting it"), kallsyms_relative_base can be larger than _text, which
causes overflow when building the 32-bit kernel.

https://lkml.org/lkml/2019/12/7/156

This is because _text is, unless --all-symbols is specified, now
trimmed from the symbol table before record_relative_base() is called.

Handle the offset signedness also for kallsyms_relative_base. Introduce
a new helper, output_address(), to reduce the code duplication.

Fixes: 5e5c4fa78745 ("scripts/kallsyms: shrink table before sorting it")
Reported-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
scripts/kallsyms.c