Hi Mark,

LGTM.

Aaron

On Wed, Nov 11, 2026 at 7:42 PM Mark Wielaard <[email protected]> wrote:
>
> A GElf_Chdr is really an Elf64_Chdr, which has a ch_reserved field,
> which is really just there to show there is padding (so the next
> fields are properly aligned for their types). A Elf32_Chdr doesn't
> have ch_reserved field (because it only contains Word sized fields).
>
> Make sure to initialize the dest ch_reserved field to zero if the src
> is a Elf32_Chdr so dest contains all defined bytes, in case it gets
> written out
>
>         * libelf/gelf_getchdr.c (gelf_getchdr): Initialize dest
>         ch_reserved field to zero.
>
> Signed-off-by: Mark Wielaard <[email protected]>
> ---
>  libelf/gelf_getchdr.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libelf/gelf_getchdr.c b/libelf/gelf_getchdr.c
> index 394bf4b3b504..4def80d85712 100644
> --- a/libelf/gelf_getchdr.c
> +++ b/libelf/gelf_getchdr.c
> @@ -53,6 +53,7 @@ gelf_getchdr (Elf_Scn *scn, GElf_Chdr *dest)
>        if (chdr == NULL)
>         return NULL;
>        dest->ch_type = chdr->ch_type;
> +      dest->ch_reserved = 0;
>        dest->ch_size = chdr->ch_size;
>        dest->ch_addralign = chdr->ch_addralign;
>      }
> --
> 2.56.0
>

Reply via email to