On Fri, May 1, 2026 at 5:09 AM Josh Poimboeuf <[email protected]> wrote: > > When computing klp checksums, instructions with non-relocated jump/call > destination offsets are problematic because the offset values can change > when surrounding code has moved, causing the function to be incorrectly > marked as changed. > > Specifically, that includes jumps from alternatives to the end of the > alternative, which from objtool's perspective are jumps to the end of > the alternative instruction block in the original function. > > Note that 'jump_dest' jumps don't include sibling calls (those use > call_dest), nor do they include jumps to/from .cold sub functions (those > are cross-section and need a reloc). > > Fix it by hashing the opcode bytes (excluding the immediate operand) > along with a position-independent representation of the destination. > For calls, use the function name, and for jumps, use the destination's > offset within its function. > > [Note the "9 bit hole" comment was wrong: it has been 8 bits since > commit 70589843b36f ("objtool: Add option to trace function validation") > added the 'trace' field. Adding the 4-bit 'immediate_len' field now > leaves a 4-bit hole.] > > Fixes: 0d83da43b1e1 ("objtool/klp: Add --checksum option to generate > per-function checksums") > Signed-off-by: Josh Poimboeuf <[email protected]>
Acked-by: Song Liu <[email protected]>

