Re: [RFC 29/31] objtool: Calculate function checksums

From: Peter Zijlstra
Date: Wed Sep 04 2024 - 03:55:50 EST


On Mon, Sep 02, 2024 at 09:00:12PM -0700, Josh Poimboeuf wrote:
> Calculate per-function checksums based on the functions' content and
> relocations. This will enable objtool to do binary diffs.
>
> Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
> ---
> scripts/Makefile.lib | 1 +
> tools/objtool/Makefile | 7 +-
> tools/objtool/builtin-check.c | 1 +
> tools/objtool/check.c | 137 +++++++++++++++++++++++-
> tools/objtool/elf.c | 31 ++++++
> tools/objtool/include/objtool/builtin.h | 3 +-
> tools/objtool/include/objtool/check.h | 5 +-
> tools/objtool/include/objtool/elf.h | 11 +-
> tools/objtool/include/objtool/objtool.h | 2 +
> 9 files changed, 188 insertions(+), 10 deletions(-)
>
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 8411e3d53938..9f4708702ef7 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -265,6 +265,7 @@ ifdef CONFIG_OBJTOOL
>
> objtool := $(objtree)/tools/objtool/objtool
>
> +objtool-args-$(CONFIG_LIVEPATCH) += --sym-checksum
> objtool-args-$(CONFIG_HAVE_JUMP_LABEL_HACK) += --hacks=jump_label
> objtool-args-$(CONFIG_HAVE_NOINSTR_HACK) += --hacks=noinstr
> objtool-args-$(CONFIG_MITIGATION_CALL_DEPTH_TRACKING) += --hacks=skylake
> diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
> index bf7f7f84ac62..6833804ca419 100644
> --- a/tools/objtool/Makefile
> +++ b/tools/objtool/Makefile
> @@ -21,6 +21,9 @@ OBJTOOL_IN := $(OBJTOOL)-in.o
> LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null)
> LIBELF_LIBS := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf)
>
> +LIBXXHASH_FLAGS := $(shell $(HOSTPKG_CONFIG) libxxhash --cflags 2>/dev/null)
> +LIBXXHASH_LIBS := $(shell $(HOSTPKG_CONFIG) libxxhash --libs 2>/dev/null || echo -lxxhash)

This was not installed on my system and I got a nasty build fail. Should
we make all this depend on CONFIG_LIVEPATCH or force world+dog to
install this as yet another kernel build dependency?