Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kbuild: remove PROVIDE() for kallsyms symbols

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>

+7 -32
-19
include/asm-generic/vmlinux.lds.h
··· 452 452 #endif 453 453 454 454 /* 455 - * Some symbol definitions will not exist yet during the first pass of the 456 - * link, but are guaranteed to exist in the final link. Provide preliminary 457 - * definitions that will be superseded in the final link to avoid having to 458 - * rely on weak external linkage, which requires a GOT when used in position 459 - * independent code. 460 - */ 461 - #define PRELIMINARY_SYMBOL_DEFINITIONS \ 462 - PROVIDE(kallsyms_addresses = .); \ 463 - PROVIDE(kallsyms_offsets = .); \ 464 - PROVIDE(kallsyms_names = .); \ 465 - PROVIDE(kallsyms_num_syms = .); \ 466 - PROVIDE(kallsyms_relative_base = .); \ 467 - PROVIDE(kallsyms_token_table = .); \ 468 - PROVIDE(kallsyms_token_index = .); \ 469 - PROVIDE(kallsyms_markers = .); \ 470 - PROVIDE(kallsyms_seqs_of_names = .); 471 - 472 - /* 473 455 * Read only Data 474 456 */ 475 457 #define RO_DATA(align) \ 476 458 . = ALIGN((align)); \ 477 - PRELIMINARY_SYMBOL_DEFINITIONS \ 478 459 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \ 479 460 __start_rodata = .; \ 480 461 *(.rodata) *(.rodata.*) \
-5
kernel/kallsyms_internal.h
··· 4 4 5 5 #include <linux/types.h> 6 6 7 - /* 8 - * These will be re-linked against their real values during the second link 9 - * stage. Preliminary values must be provided in the linker script using the 10 - * PROVIDE() directive so that the first link stage can complete successfully. 11 - */ 12 7 extern const unsigned long kallsyms_addresses[]; 13 8 extern const int kallsyms_offsets[]; 14 9 extern const u8 kallsyms_names[];
-6
scripts/kallsyms.c
··· 259 259 } 260 260 } 261 261 table_cnt = pos; 262 - 263 - /* When valid symbol is not registered, exit to error */ 264 - if (!table_cnt) { 265 - fprintf(stderr, "No valid symbol.\n"); 266 - exit(1); 267 - } 268 262 } 269 263 270 264 static void read_map(const char *in)