[PATCH] debugedit: Use ELF_F_PERMISSIVE when using ELF_F_LAYOUT

Mark Wielaard mark@klomp.org
Tue Jun 16 12:48:07 GMT 2026


Hi,

On Fri, 2026-06-05 at 15:07 +0200, Mark Wielaard wrote:
> Normally elf_update will do some strict checks on sections,
> specifically it will check that sh_size is a multiple of sh_entsize
> (if not zero).  This might prevent debugedit from writing out some
> sections it just wants to keep unchanged (even if they aren't strictly
> valid ELF).
> 
> 	* tools/debugedit.c (fdopen_dso): Set elf_flagelf
> 	ELF_F_PERMISSIVE.

Pushed this.

> Signed-off-by: Mark Wielaard <mark@klomp.org>
> ---
>  tools/debugedit.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/debugedit.c b/tools/debugedit.c
> index 03788ff92a70..d473b80dae4b 100644
> --- a/tools/debugedit.c
> +++ b/tools/debugedit.c
> @@ -3638,7 +3638,15 @@ fdopen_dso (int fd, const char *name)
>    /* If there are phdrs we want to maintain the layout of the
>       allocated sections in the file.  */
>    if (phnum != 0)
> -    elf_flagelf (elf, ELF_C_SET, ELF_F_LAYOUT);
> +    {
> +      elf_flagelf (elf, ELF_C_SET, ELF_F_LAYOUT);
> +      /* Normally elf_update will do some strict checks on sections,
> +	 specifically it will check that sh_size is a multiple of
> +	 sh_entsize (if not zero).  This might prevent debugedit from
> +	 writing out some sections it just wants to keep unchanged
> +	 (even if they aren't strictly valid ELF).  */
> +      elf_flagelf (elf, ELF_C_SET, ELF_F_PERMISSIVE);
> +    }
>  
>    memset (dso, 0, sizeof(DSO));
>    dso->elf = elf;


More information about the Debugedit mailing list