Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create-diff-object: support x86 NOP-padded functions
Kernel v6.2+ commit bea75b33895f ("x86/Kconfig: Introduce function padding") added 16 bytes of NOP padding in front of each function. For objects built with --function-sections, this means that function symbols no longer sit at the beginning of their respective ELF sections, but 16 bytes offset. In the same release, kernel v6.2+ commit 9f2899fe36a6 ("objtool: Add option to generate prefix symbols") adds ELF function symbols with prefix "__pfx_" to indicate the start of a function, inclusive of NOP-padding. For example: $ objdump -Dr -j.text.cmdline_proc_show fs/proc/cmdline.o ... Disassembly of section .text.cmdline_proc_show: 0000000000000000 <__pfx_cmdline_proc_show>: 0: 90 nop 1: 90 nop 2: 90 nop 3: 90 nop 4: 90 nop 5: 90 nop 6: 90 nop 7: 90 nop 8: 90 nop 9: 90 nop a: 90 nop b: 90 nop c: 90 nop d: 90 nop e: 90 nop f: 90 nop 0000000000000010 <cmdline_proc_show>: 10: e8 00 00 00 00 callq 15 <cmdline_proc_show+0x5> 11: R_X86_64_PLT32 __fentry__-0x4 15: 55 push %rbp 16: 48 8b 35 00 00 00 00 mov 0x0(%rip),%rsi # 1d <cmdline_proc_show+0xd> 19: R_X86_64_PC32 saved_command_line-0x4 1d: 48 89 fd mov %rdi,%rbp 20: e8 00 00 00 00 callq 25 <cmdline_proc_show+0x15> 21: R_X86_64_PLT32 seq_puts-0x4 25: 48 89 ef mov %rbp,%rdi 28: be 0a 00 00 00 mov $0xa,%esi 2d: e8 00 00 00 00 callq 32 <cmdline_proc_show+0x22> 2e: R_X86_64_PLT32 seq_putc-0x4 32: 31 c0 xor %eax,%eax 34: 5d pop %rbp 35: e9 00 00 00 00 jmpq 3a <cmdline_proc_show+0x2a> 36: R_X86_64_PLT32 __x86_return_thunk-0x4 Kpatch-build needs to gracefully handle NOP-padding when it is present. At the same time, it should include "__pfx_<function>" symbols when their respective functions change, but not treat prefix such functions as first-class functions. This also adds support for CONFIG_CFI_CLANG, which also creates prefixed symbols with the name "__cfi_<function>". Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
- Loading branch information