build: provide option to disambiguate symbol names
authorJan Beulich <jbeulich@suse.com>
Thu, 28 Nov 2019 16:47:25 +0000 (17:47 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 28 Nov 2019 16:47:25 +0000 (17:47 +0100)
commit81ecb38b83b0e9e11d9baecaa36458edc44a3edb
treeed8209ef669d0f30ce1c5f76631f42c1cd6bc0b9
parent5655ce8b1ec2a82ef080078e41c73bbd536174e1
build: provide option to disambiguate symbol names

The .file assembler directives generated by the compiler do not include
any path components (gcc) or just the ones specified on the command line
(clang, at least version 5), and hence multiple identically named source
files (in different directories) may produce identically named static
symbols (in their kallsyms representation). The binary diffing algorithm
used by xen-livepatch, however, depends on having unique symbols.

Make the ENFORCE_UNIQUE_SYMBOLS Kconfig option control the (build)
behavior, and if enabled use objcopy to prepend the (relative to the
xen/ subdirectory) path to the compiler invoked STT_FILE symbols. Note
that this build option is made no longer depend on LIVEPATCH, but merely
defaults to its setting now.

Conditionalize explicit .file directive insertion in C files where it
exists just to disambiguate names in a less generic manner; note that
at the same time the redundant emission of STT_FILE symbols gets
suppressed for clang. Assembler files as well as multiply compiled C
ones using __OBJECT_FILE__ are left alone for the time being.

Since we now expect there not to be any duplicates anymore, also don't
force the selection of the option to 'n' anymore in allrandom.config.
Similarly COVERAGE no longer suppresses duplicate symbol warnings if
enforcement is in effect, which in turn allows
SUPPRESS_DUPLICATE_SYMBOL_WARNINGS to simply depend on
!ENFORCE_UNIQUE_SYMBOLS.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Wei Liu <wl@xen.org>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Tested-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
13 files changed:
xen/Kconfig.debug
xen/Rules.mk
xen/arch/x86/x86_64/compat.c
xen/arch/x86/x86_64/mm.c
xen/arch/x86/x86_64/physdev.c
xen/arch/x86/x86_64/platform_hypercall.c
xen/common/Kconfig
xen/common/compat/domain.c
xen/common/compat/kernel.c
xen/common/compat/memory.c
xen/common/compat/multicall.c
xen/include/xen/config.h
xen/tools/kconfig/allrandom.config