mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-02 01:08:26 -04:00
Add a --debug-checksum=<funcs> option to the check subcommand to print the calculated checksum of each instruction in the given functions. This is useful for determining where two versions of a function begin to diverge. Acked-by: Petr Mladek <pmladek@suse.com> Tested-by: Joe Lawrence <joe.lawrence@redhat.com> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
44 lines
1.1 KiB
C
44 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
#ifndef _OBJTOOL_CHECKSUM_H
|
|
#define _OBJTOOL_CHECKSUM_H
|
|
|
|
#include <objtool/elf.h>
|
|
|
|
#ifdef BUILD_KLP
|
|
|
|
static inline void checksum_init(struct symbol *func)
|
|
{
|
|
if (func && !func->csum.state) {
|
|
func->csum.state = XXH3_createState();
|
|
XXH3_64bits_reset(func->csum.state);
|
|
}
|
|
}
|
|
|
|
static inline void checksum_update(struct symbol *func,
|
|
struct instruction *insn,
|
|
const void *data, size_t size)
|
|
{
|
|
XXH3_64bits_update(func->csum.state, data, size);
|
|
dbg_checksum(func, insn, XXH3_64bits_digest(func->csum.state));
|
|
}
|
|
|
|
static inline void checksum_finish(struct symbol *func)
|
|
{
|
|
if (func && func->csum.state) {
|
|
func->csum.checksum = XXH3_64bits_digest(func->csum.state);
|
|
func->csum.state = NULL;
|
|
}
|
|
}
|
|
|
|
#else /* !BUILD_KLP */
|
|
|
|
static inline void checksum_init(struct symbol *func) {}
|
|
static inline void checksum_update(struct symbol *func,
|
|
struct instruction *insn,
|
|
const void *data, size_t size) {}
|
|
static inline void checksum_finish(struct symbol *func) {}
|
|
|
|
#endif /* !BUILD_KLP */
|
|
|
|
#endif /* _OBJTOOL_CHECKSUM_H */
|