Hi Aaron,
On Sun, 2025-10-05 at 21:39 -0400, Aaron Merey wrote:
> Signed-off-by: Aaron Merey <[email protected]>
>
> ---
> v2: Mention that for ELFCLASS32 binaries ehdr values must be
> expressible as 32-bit values. Also fix formating in the RETURN
> VALUE section.
Looks good. One minor nitpick below.
> doc/Makefile.am | 1 +
> doc/gelf_update_ehdr.3 | 78 ++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 79 insertions(+)
> create mode 100644 doc/gelf_update_ehdr.3
>
> diff --git a/doc/Makefile.am b/doc/Makefile.am
> index 3c22f0aa..c0d979ec 100644
> --- a/doc/Makefile.am
> +++ b/doc/Makefile.am
> @@ -93,6 +93,7 @@ notrans_dist_man3_MANS= elf32_checksum.3 \
> elf_version.3 \
> gelf_getclass.3 \
> gelf_getehdr.3 \
> + gelf_update_ehdr.3 \
> libelf.3
OK.
> # libdebuginfod man pages (also notrans)
> diff --git a/doc/gelf_update_ehdr.3 b/doc/gelf_update_ehdr.3
> new file mode 100644
> index 00000000..d1e7ab68
> --- /dev/null
> +++ b/doc/gelf_update_ehdr.3
> @@ -0,0 +1,78 @@
> +.TH GELF_UPDATE_EHDR 3 2025-09-17 "Libelf" "Libelf Programmer's Manual"
> +
> +.SH NAME
> +gelf_update_ehdr \- copy a class\-independent ELF header into an ELF
> descriptor
> +
> +.SH SYNOPSIS
> +.nf
> +.B #include <gelf.h>
> +
> +.BI "int gelf_update_ehdr(Elf *" elf ", GElf_Ehdr *" src ");"
> +.fi
OK.
> +.SH DESCRIPTION
> +.BR gelf_update_ehdr ()
> +copies the class\-independent ELF header from the structure pointed to by
> +.I src
> +into the ELF descriptor
> +.I elf .
> +The header is translated as necessary to match the class (
> +.B ELFCLASS32
> +or
> +.BR ELFCLASS64 )
> +of the underlying object.
> +
> +If
> +.I elf
> +has class
> +.B ELFCLASS32
> +then
> +.BR e_entry ,
> +.B e_phoff
> +and
> +.B e_shoff
> +must be expressible as 32-bit values. This function also marks the Ehdr
> +dirty (see
> +.BR elf_flagehdr ()).
OK.
> +.SH PARAMETERS
> +.TP
> +.I elf
> +Pointer to an ELF descriptor of kind
> +.BR ELF_K_ELF .
> +
> +.TP
> +.I src
> +Pointer to a
> +.B GElf_Ehdr
> +structure that holds the caller’s desired header contents. Must not be NULL.
OK.
> +.SH RETURN VALUE
> +On success,
> +.BR gelf_update_ehdr ()
> +returns 1. On failure, it returns 0 and sets elf_errno. If
> +.I elf
> +is NULL, then 0 is returned without setting elf_errno.
As with other gelf functions I think we should only promise that zero
is returned on error and something non-zero on success, but not a
specific value.
> +.SH SEE ALSO
> +.BR gelf_getehdr (3),
> +.BR gelf_newehdr (3),
> +.BR elf_flagehdr (3),
> +.BR libelf (3),
> +.BR elf (5)
OK.
> +.SH ATTRIBUTES
> +.TS
> +allbox;
> +lbx lb lb
> +l l l.
> +Interface Attribute Value
> +T{
> +.na
> +.nh
> +.BR gelf_update_ehdr ()
> +T} Thread safety MT-Safe
> +.TE
> +
> +.SH REPORTING BUGS
> +Report bugs to <[email protected]> or
> https://sourceware.org/bugzilla/.
OK.
Thanks,
Mark