Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-06-10 Thread Josh Poimboeuf
On Tue, Jun 10, 2025 at 08:39:10AM -0400, Joe Lawrence wrote: > >> Should we check for other data section prefixes here, like: > >> > >>else { > >>snprintf(sec_name, SEC_NAME_LEN, ".rodata.%s", > >> sym->name); > >>if (!st

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-06-10 Thread Joe Lawrence
On 6/9/25 7:21 PM, Josh Poimboeuf wrote: > On Mon, Jun 09, 2025 at 02:32:19PM -0400, Joe Lawrence wrote: >> On Fri, May 09, 2025 at 01:17:16PM -0700, Josh Poimboeuf wrote: >>> +static int validate_ffunction_fdata_sections(struct elf *elf) >>> +{ >>> + struct symbol *sym; >>> + bool found_text =

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-06-09 Thread Josh Poimboeuf
On Mon, Jun 09, 2025 at 02:32:19PM -0400, Joe Lawrence wrote: > On Fri, May 09, 2025 at 01:17:16PM -0700, Josh Poimboeuf wrote: > > +static int validate_ffunction_fdata_sections(struct elf *elf) > > +{ > > + struct symbol *sym; > > + bool found_text = false, found_data = false; > > + > > + fo

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-06-09 Thread Joe Lawrence
On Fri, May 09, 2025 at 01:17:16PM -0700, Josh Poimboeuf wrote: > +static int validate_ffunction_fdata_sections(struct elf *elf) > +{ > + struct symbol *sym; > + bool found_text = false, found_data = false; > + > + for_each_sym(elf, sym) { > + char sec_name[SEC_NAME_LEN]; >

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-06-05 Thread Josh Poimboeuf
On Mon, May 26, 2025 at 08:57:16PM +0200, Peter Zijlstra wrote: > > @@ -50,10 +51,12 @@ struct section { > > bool _changed, text, rodata, noinstr, init, truncate; > > struct reloc *relocs; > > unsigned long nr_alloc_relocs; > > + struct section *twin; > > }; > > > > struct symbol

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-06-05 Thread Josh Poimboeuf
On Mon, May 26, 2025 at 08:50:40PM +0200, Peter Zijlstra wrote: > > Let me hand you a fresh bucket of curlies, you must've run out :-) Thanks for the freebies, imported curlies aren't so cheap these days! -- Josh

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-06-05 Thread Josh Poimboeuf
On Mon, May 26, 2025 at 08:47:00PM +0200, Peter Zijlstra wrote: > On Fri, May 09, 2025 at 01:17:16PM -0700, Josh Poimboeuf wrote: > > +#define SEC_NAME_LEN 512 > > #define SYM_NAME_LEN 512 > > > > > +static int validate_ffunction_fdata_sections(struct elf *elf) > > +

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-06-05 Thread Josh Poimboeuf
On Mon, May 26, 2025 at 08:27:19PM +0200, Peter Zijlstra wrote: > On Fri, May 09, 2025 at 01:17:16PM -0700, Josh Poimboeuf wrote: > > +static void scan_for_insn(struct section *sec, unsigned long offset, > > + unsigned long *insn_off, unsigned int *insn_len) > > +{ > > + unsig

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-06-04 Thread Josh Poimboeuf
On Mon, May 26, 2025 at 08:22:59PM +0200, Peter Zijlstra wrote: > On Fri, May 09, 2025 at 01:17:16PM -0700, Josh Poimboeuf wrote: > > > Without '-ffunction-sections -fdata-sections', reliable object diffing > > would be infeasible due to toolchain limitations: > > > > - For intra-file+intra-sec

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-05-26 Thread Peter Zijlstra
On Fri, May 09, 2025 at 01:17:16PM -0700, Josh Poimboeuf wrote: > +#define KLP_RELOC_SEC_PREFIX ".klp.rela." > +#define KLP_SYM_PREFIX ".klp.sym." This max symbol length test is getting more and more broken every day :-)

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-05-26 Thread Peter Zijlstra
On Fri, May 09, 2025 at 01:17:16PM -0700, Josh Poimboeuf wrote: > diff --git a/tools/objtool/include/objtool/elf.h > b/tools/objtool/include/objtool/elf.h > index 4cfd09e66cb5..f62ac8081f27 100644 > --- a/tools/objtool/include/objtool/elf.h > +++ b/tools/objtool/include/objtool/elf.h > @@ -17,6 +1

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-05-26 Thread Peter Zijlstra
Let me hand you a fresh bucket of curlies, you must've run out :-) On Fri, May 09, 2025 at 01:17:16PM -0700, Josh Poimboeuf wrote: > +static struct symbol *first_file_symbol(struct elf *elf) > +{ > + struct symbol *sym; > + > + for_each_sym(elf, sym) { > + if (is_file_sym

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-05-26 Thread Peter Zijlstra
On Fri, May 09, 2025 at 01:17:16PM -0700, Josh Poimboeuf wrote: > +#define SEC_NAME_LEN 512 > #define SYM_NAME_LEN 512 > > +static int validate_ffunction_fdata_sections(struct elf *elf) > +{ > + struct symbol *sym; > + bool found_text = false, found_data = false; > + > +

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-05-26 Thread Peter Zijlstra
On Fri, May 09, 2025 at 01:17:16PM -0700, Josh Poimboeuf wrote: > diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c > index cdf385e54c69..ae4f83fcbadf 100644 > --- a/tools/objtool/arch/x86/decode.c > +++ b/tools/objtool/arch/x86/decode.c > @@ -95,6 +95,46 @@ s64 arch_in

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-05-26 Thread Peter Zijlstra
On Fri, May 09, 2025 at 01:17:16PM -0700, Josh Poimboeuf wrote: > Without '-ffunction-sections -fdata-sections', reliable object diffing > would be infeasible due to toolchain limitations: > > - For intra-file+intra-section references, the compiler might > occasionally generated hard-coded

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-05-14 Thread laokz
On 5/14/2025 4:45 AM, Josh Poimboeuf wrote: On Tue, May 13, 2025 at 10:49:59PM +0800, laokz wrote: On 5/10/2025 4:17 AM, Josh Poimboeuf wrote: + +#define sym_for_each_reloc(elf, sym, reloc)\ + for (reloc = find_reloc_by_dest_range(elf, sym->sec, \ +

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-05-13 Thread Josh Poimboeuf
On Tue, May 13, 2025 at 10:49:59PM +0800, laokz wrote: > On 5/10/2025 4:17 AM, Josh Poimboeuf wrote: > > + > > +#define sym_for_each_reloc(elf, sym, reloc) > > \ > > + for (reloc = find_reloc_by_dest_range(elf, sym->sec,\ > > +

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-05-13 Thread laokz
On 5/10/2025 4:17 AM, Josh Poimboeuf wrote: + +#define sym_for_each_reloc(elf, sym, reloc)\ + for (reloc = find_reloc_by_dest_range(elf, sym->sec, \ + sym->offset, sym->len); \ +reloc && reloc_of

[PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-05-09 Thread Josh Poimboeuf
Add a new klp diff subcommand which performs a binary diff between two object files and extracts changed functions into a new object which can then be linked into a livepatch module. This builds on concepts from the longstanding out-of-tree kpatch [1] project which began in 2012 and has been used