Re: [PATCH v3 5/9] modpost: Integrate klp-convert

From: Joe Lawrence
Date: Thu Apr 11 2019 - 11:54:42 EST


On Wed, Apr 10, 2019 at 11:50:54AM -0400, Joe Lawrence wrote:
>
> [ ... snip ... ]
>
> diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
> index 6b7f354f189a..1e8bb7442689 100644
> --- a/scripts/Makefile.modpost
> +++ b/scripts/Makefile.modpost
> @@ -124,8 +124,22 @@ quiet_cmd_ld_ko_o = LD [M] $@
> -o $@ $(real-prereqs) ; \
> $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
>
> +SLIST = $(objtree)/Symbols.list
> +KLP_CONVERT = scripts/livepatch/klp-convert
> +quiet_cmd_klp_convert = KLP $@
> + cmd_klp_convert = mv $@ $(@:.ko=.klp.o); \
> + $(KLP_CONVERT) $(SLIST) $(@:.ko=.klp.o) $@
> +
> +define rule_ld_ko_o
> + $(call echo-cmd,ld_ko_o) $(cmd_ld_ko_o) ; \
> + $(call save-cmd,ld_ko_o) ; \
> + $(if $(CONFIG_LIVEPATCH), \
> + $(if $(wildcard $(MODVERDIR)/$(basetarget).livepatch), \
> + $(call echo-cmd,klp_convert) $(cmd_klp_convert) ))
> +endef
> +
> $(modules): %.ko :%.o %.mod.o FORCE
> - +$(call if_changed,ld_ko_o)
> + +$(call if_changed_rule,ld_ko_o)
>
> targets += $(modules)

I just noticed that rule_ld_ko_o produces verbose output when linking
modules:

% make
...
echo ' LD [M] drivers/ata/ata_generic.ko'; ld -r -m elf_x86_64 -z max-page-size=0x200000 -T ./scripts/module-common.lds --build-id -o drivers/ata/ata_generic.ko drivers/ata/ata_generic.o drivers/ata/ata_generic.mod.o ; true ; printf '%s\n' 'cmd_drivers/ata/ata_generic.ko := ld -r -m elf_x86_64 -z max-page-size=0x200000 -T ./scripts/module-common.lds --build-id -o drivers/ata/ata_generic.ko drivers/ata/ata_generic.o drivers/ata/ata_generic.mod.o ; true' > drivers/ata/.ata_generic.ko.cmd ;
LD [M] drivers/ata/ata_generic.ko

so I think we need to use the $(Q) macro to respect the KBUILD_VERBOSE
and V kbuild settings.

Masahiro, does something like this look correct?


Thanks,

-- Joe

-->8-- -->8-- -->8-- -->8-- -->8-- -->8-- -->8-- -->8-- -->8-- -->8--