Re: [PATCH v2 21/26] genksyms: adjust the output format for .cmd files

Nicolas Schier
2022-05-04T20:23:53Z

On sø. 01. mai 2022 kl. 17.40 Masahiro Yamada wrote:
> genksyms output symbol versions in the linker script format.

output -> outputs ?

> The output format depends on CONFIG_MODULE_REL_CRCS.

Looking at the patch itself, I think the sentence above should be
inverted, as all rel_crc special handling is removed. Or did I get it
wrong?

Kind regards,
Nicolas

>
> Now, symbol versions are passed to modpost as plain text data,
> we can simplify the genksyms code.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
> Changes in v2:
> - New patch
>
> scripts/Makefile.build | 9 ---------
> scripts/genksyms/genksyms.c | 17 ++++-------------
> 2 files changed, 4 insertions(+), 22 deletions(-)
>
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 10092efb61ac..1f480e4ff70a 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -128,7 +128,6 @@ $(obj)/%.i: $(src)/%.c FORCE
>
> genksyms = scripts/genksyms/genksyms \
> $(if $(1), -T $(2)) \
> - $(if $(CONFIG_MODULE_REL_CRCS), -R) \
> $(if $(KBUILD_PRESERVE), -p) \
> -r $(or $(wildcard $(2:.symtypes=.symref)), /dev/null)
>
> @@ -166,18 +165,10 @@ ifdef CONFIG_MODVERSIONS
> # o modpost will extract versions from the .cmd file and create linker
> # scripts used to link the kernel and/or modules.
>
> -genksyms_format_rel_crc := [^_]*__crc_\([^ ]*\) = \.; LONG(\([^)]*\)).*
> -genksyms_format_normal := __crc_\(.*\) = \(.*\);
> -genksyms_format := $(if $(CONFIG_MODULE_REL_CRCS),$(genksyms_format_rel_crc),$(genksyms_format_normal))
> -
> gen_symversions = \
> if $(NM) $@ 2>/dev/null | grep -q __ksymtab; then \
> $(call cmd_gensymtypes_$(1),$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
> - > $@.symversions; \
> - sed -n 's/$(genksyms_format)/$(pound)SYMVER \1 \2/p' $@.symversions \
> >> $(dot-target).cmd; \
> - else \
> - rm -f $@.symversions; \
> fi
>
> cmd_gen_symversions_c = $(call gen_symversions,c)
> diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
> index 4827c5abe5b7..ec5ad4405483 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;
> @@ -680,11 +680,7 @@ void export_symbol(const char *name)
> if (flag_dump_defs)
> fputs(">\n", debugfile);
>
> - /* Used as a linker script. */
> - printf(!flag_rel_crcs ? "__crc_%s = 0x%08lx;\n" :
> - "SECTIONS { .rodata : ALIGN(4) { "
> - "__crc_%s = .; LONG(0x%08lx); } }\n",
> - name, crc);
> + printf("#SYMVER %s 0x%08lx\n", name, crc);
> }
> }
>
> @@ -745,7 +741,6 @@ static void genksyms_usage(void)
> " -q Disable warnings (default)\n"
> " -h Print this message\n"
> " -V Print the release version\n"
> - " -R Emit section relative symbol CRCs\n"
> #endif /* __GNU_LIBRARY__ */
> , stderr);
> }
> @@ -766,14 +761,13 @@ int main(int argc, char **argv)
> {"preserve", 0, 0, 'p'},
> {"version", 0, 0, 'V'},
> {"help", 0, 0, 'h'},
> - {"relative-crc", 0, 0, 'R'},
> {0, 0, 0, 0}
> };
>
> - while ((o = getopt_long(argc, argv, "s:dwqVDr:T:phR",
> + while ((o = getopt_long(argc, argv, "s:dwqVDr:T:ph",
> &long_opts[0], NULL)) != EOF)
> #else /* __GNU_LIBRARY__ */
> - while ((o = getopt(argc, argv, "s:dwqVDr:T:phR")) != EOF)
> + while ((o = getopt(argc, argv, "s:dwqVDr:T:ph")) != EOF)
> #endif /* __GNU_LIBRARY__ */
> switch (o) {
> case 'd':
> @@ -813,9 +807,6 @@ int main(int argc, char **argv)
> case 'h':
> genksyms_usage();
> return 0;
> - case 'R':
> - flag_rel_crcs = 1;
> - break;
> default:
> genksyms_usage();
> return 1;
> --
> 2.32.0

--
epost|xmpp: nicolas@fjasle.eu irc://oftc.net/nsc
↳ gpg: 18ed 52db e34f 860e e9fb c82b 7d97 0932 55a0 ce7f
-- frykten for herren er opphav til kunnskap --