kbuild: remove PROVIDE() for kallsyms symbols
BugLink: https://bugs.launchpad.net/bugs/2084005 [ Upstream commit c442db3f49f27e5a60a641b2ac9a3c6320796ed6 ] This reimplements commit 951bcae6c5a0 ("kallsyms: Avoid weak references for kallsyms symbols") because I am not a big fan of PROVIDE(). As an alternative solution, this commit prepends one more kallsyms step. KSYMS .tmp_vmlinux.kallsyms0.S # added AS .tmp_vmlinux.kallsyms0.o # added LD .tmp_vmlinux.btf BTF .btf.vmlinux.bin.o LD .tmp_vmlinux.kallsyms1 NM .tmp_vmlinux.kallsyms1.syms KSYMS .tmp_vmlinux.kallsyms1.S AS .tmp_vmlinux.kallsyms1.o LD .tmp_vmlinux.kallsyms2 NM .tmp_vmlinux.kallsyms2.syms KSYMS .tmp_vmlinux.kallsyms2.S AS .tmp_vmlinux.kallsyms2.o LD vmlinux Step 0 takes /dev/null as input, and generates .tmp_vmlinux.kallsyms0.o, which has a valid kallsyms format with the empty symbol list, and can be linked to vmlinux. Since it is really small, the added compile-time cost is negligible. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Acked-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu> Stable-dep-of: 020925ce9299 ("kallsyms: Do not cleanup .llvm.<hash> suffix before sorting symbols") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Koichiro Den <koichiro.den@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
This commit is contained in:
committed by
Mehmet Basaran
parent
7998f20ffc
commit
87a53954d8
@@ -448,30 +448,11 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Some symbol definitions will not exist yet during the first pass of the
|
||||
* link, but are guaranteed to exist in the final link. Provide preliminary
|
||||
* definitions that will be superseded in the final link to avoid having to
|
||||
* rely on weak external linkage, which requires a GOT when used in position
|
||||
* independent code.
|
||||
*/
|
||||
#define PRELIMINARY_SYMBOL_DEFINITIONS \
|
||||
PROVIDE(kallsyms_addresses = .); \
|
||||
PROVIDE(kallsyms_offsets = .); \
|
||||
PROVIDE(kallsyms_names = .); \
|
||||
PROVIDE(kallsyms_num_syms = .); \
|
||||
PROVIDE(kallsyms_relative_base = .); \
|
||||
PROVIDE(kallsyms_token_table = .); \
|
||||
PROVIDE(kallsyms_token_index = .); \
|
||||
PROVIDE(kallsyms_markers = .); \
|
||||
PROVIDE(kallsyms_seqs_of_names = .);
|
||||
|
||||
/*
|
||||
* Read only Data
|
||||
*/
|
||||
#define RO_DATA(align) \
|
||||
. = ALIGN((align)); \
|
||||
PRELIMINARY_SYMBOL_DEFINITIONS \
|
||||
.rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
|
||||
__start_rodata = .; \
|
||||
*(.rodata) *(.rodata.*) \
|
||||
|
||||
@@ -4,11 +4,6 @@
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
/*
|
||||
* These will be re-linked against their real values during the second link
|
||||
* stage. Preliminary values must be provided in the linker script using the
|
||||
* PROVIDE() directive so that the first link stage can complete successfully.
|
||||
*/
|
||||
extern const unsigned long kallsyms_addresses[];
|
||||
extern const int kallsyms_offsets[];
|
||||
extern const u8 kallsyms_names[];
|
||||
|
||||
@@ -246,12 +246,6 @@ static void shrink_table(void)
|
||||
}
|
||||
}
|
||||
table_cnt = pos;
|
||||
|
||||
/* When valid symbol is not registered, exit to error */
|
||||
if (!table_cnt) {
|
||||
fprintf(stderr, "No valid symbol.\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
static void read_map(const char *in)
|
||||
|
||||
@@ -228,6 +228,10 @@ btf_vmlinux_bin_o=
|
||||
kallsymso=
|
||||
strip_debug=
|
||||
|
||||
if is_enabled CONFIG_KALLSYMS; then
|
||||
kallsyms /dev/null .tmp_vmlinux.kallsyms0
|
||||
fi
|
||||
|
||||
if is_enabled CONFIG_DEBUG_INFO_BTF; then
|
||||
if ! gen_btf .tmp_vmlinux.btf .btf.vmlinux.bin.o ; then
|
||||
echo >&2 "Failed to generate BTF for vmlinux"
|
||||
@@ -240,9 +244,10 @@ if is_enabled CONFIG_KALLSYMS; then
|
||||
|
||||
# kallsyms support
|
||||
# Generate section listing all symbols and add it into vmlinux
|
||||
# It's a three step process:
|
||||
# It's a four step process:
|
||||
# 0) Generate a dummy __kallsyms with empty symbol list.
|
||||
# 1) Link .tmp_vmlinux.kallsyms1 so it has all symbols and sections,
|
||||
# but __kallsyms is empty.
|
||||
# with a dummy __kallsyms.
|
||||
# Running kallsyms on that gives us .tmp_kallsyms1.o with
|
||||
# the right size
|
||||
# 2) Link .tmp_vmlinux.kallsyms2 so it now has a __kallsyms section of
|
||||
|
||||
Reference in New Issue
Block a user