Re: [PATCH v4 06/14] kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS

From: Nick Desaulniers
Date: Mon May 09 2022 - 13:51:12 EST


On Sun, May 8, 2022 at 12:10 PM Masahiro Yamada <masahiroy@xxxxxxxxxx> wrote:
>
> diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h
> index 07a36a874dca..51ce72ce80fa 100644
> --- a/include/asm-generic/export.h
> +++ b/include/asm-generic/export.h
> @@ -2,6 +2,14 @@
> #ifndef __ASM_GENERIC_EXPORT_H
> #define __ASM_GENERIC_EXPORT_H
>
> +/*
> + * This comment block is used by fixdep. Please do not remove.

I don't know much about fixdep. How does that work, if you could summarize?

> + *
> + * When CONFIG_MODVERSIONS is changed from n to y, all source files having
> + * EXPORT_SYMBOL variants must be re-compiled because genksyms is run as a
> + * side effect of the .o build rule.
> + */
> +
> #ifndef KSYM_FUNC
> #define KSYM_FUNC(x) x
> #endif
> @@ -12,9 +20,6 @@
> #else
> #define KSYM_ALIGN 4
> #endif
> -#ifndef KCRC_ALIGN
> -#define KCRC_ALIGN 4
> -#endif

The #ifndef is there because arch/m68k/include/asm/export.h:1 defines
KCRC_ALIGN. You should delete that, too.

> diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
> index 4827c5abe5b7..6e6933ae7911 100644
> --- a/scripts/genksyms/genksyms.c
> +++ b/scripts/genksyms/genksyms.c
> @@ -33,7 +33,7 @@ char *cur_filename;
> int in_source_file;
>
> static int flag_debug, flag_dump_defs, flag_reference, flag_dump_types,
> - flag_preserve, flag_warnings, flag_rel_crcs;
> + flag_preserve, flag_warnings;
>
> static int errors;
> static int nsyms;
> @@ -681,10 +681,7 @@ void export_symbol(const char *name)
> fputs(">\n", debugfile);
>
> /* Used as a linker script. */

^ Does this comment still apply?

> - printf(!flag_rel_crcs ? "__crc_%s = 0x%08lx;\n" :
> - "SECTIONS { .rodata : ALIGN(4) { "
> - "__crc_%s = .; LONG(0x%08lx); } }\n",
> - name, crc);
> + printf("__crc_%s = 0x%08lx;\n", name, crc);
> }
> }
>
> diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> index eceb3ee7ec06..6aee2401f3ad 100755
> --- a/scripts/link-vmlinux.sh
> +++ b/scripts/link-vmlinux.sh
> @@ -88,11 +88,6 @@ modpost_link()
> gen_initcalls
> lds="-T .tmp_initcalls.lds"
>
> - if is_enabled CONFIG_MODVERSIONS; then
> - gen_symversions

^ this is the only caller of gen_symversions, right? Then
gen_symversions can be cleaned up, too?

> - lds="${lds} -T .tmp_symversions.lds"
> - fi
> -
> # This might take a while, so indicate that we're doing
> # an LTO link
> info LTO ${1}
> @@ -183,6 +178,10 @@ vmlinux_link()
> libs="${KBUILD_VMLINUX_LIBS}"
> fi
>
> + if is_enabled CONFIG_MODULES; then
> + objs="${objs} .vmlinux.export.o"
> + fi
> +
> if [ "${SRCARCH}" = "um" ]; then
> wl=-Wl,
> ld="${CC}"
> @@ -312,6 +311,7 @@ cleanup()
> rm -f vmlinux.o
> rm -f .vmlinux.d
> rm -f .vmlinux.objs
> + rm -f .vmlinux.export.c

Probably can drop the `rm -f .tmp_symversions.lds` here, too?
--
Thanks,
~Nick Desaulniers