From: Aaron Merey Date: Tue, 28 Oct 2025 22:26:31 +0000 (-0400) Subject: doc: Add gelf_newphdr.3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=180a3c9d3932815ea49c46ac423bc07f24dae099;p=thirdparty%2Felfutils.git doc: Add gelf_newphdr.3 Signed-off-by: Aaron Merey --- diff --git a/doc/Makefile.am b/doc/Makefile.am index d8bbca55..db566bce 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -94,6 +94,7 @@ notrans_dist_man3_MANS= elf32_checksum.3 \ gelf_getclass.3 \ gelf_getehdr.3 \ gelf_getshdr.3 \ + gelf_newphdr.3 \ gelf_offscn.3 \ libelf.3 diff --git a/doc/gelf_newphdr.3 b/doc/gelf_newphdr.3 new file mode 100644 index 00000000..a94697c1 --- /dev/null +++ b/doc/gelf_newphdr.3 @@ -0,0 +1,87 @@ +.TH GELF_NEWPHDR 3 2025-09-23 "Libelf" "Libelf Programmer's Manual" + +.SH NAME +gelf_newphdr \- allocate and initialize a new program header table + +.SH SYNOPSIS +.nf +.B #include + +.BI "void *gelf_newphdr(Elf *" elf ", size_t " phnum ");" +.fi + +.SH DESCRIPTION +.BR gelf_newphdr () +creates a new program header table with +.I phnum +entries for the ELF descriptor +.IR elf , +zeroing all entries. If a program header table already exists for +.IR elf , +it is discarded. If +.I phnum +is zero, any existing program header table is removed. + +.PP +This array is maintained within the ELF descriptor and must not be freed +directly. After calling +.BR gelf_newphdr (), +any previously obtained program header pointers for the same descriptor +become invalid. An ELF header must exist before creating a program header +table. + +.SH PARAMETERS +.TP +.I elf +Pointer to an ELF descriptor of kind +.BR ELF_K_ELF . + +.TP +.I phnum +Number of entries in the new program header table. If zero, any existing +program header table is removed. + +.SH RETURN VALUE +On success, returns a non-NULL void pointer to the new program header table. +The new program header table can be retrieved as a +.B GElf_Phdr * +using +.BR gelf_getphdr (). +.BR elf32_getphdr () +or +.BR elf64_getphdr () +can also be used depending on the class of +.IR elf . +If +.I phnum +is 0, then any existing program header table is removed and NULL is returned. +On failure, NULL is returned and elf_errno is set. If +.I elf +is NULL, then NULL is returned without setting elf_errno. + +Other libelf implementations of +.BR gelf_newphdr () +may use a different return type. + +.SH SEE ALSO +.BR gelf_getphdr (3), +.BR gelf_update_phdr (3), +.BR libelf (3), +.BR elf (5) + +.SH ATTRIBUTES + +.TS +allbox; +lbx lb lb +l l l. +Interface Attribute Value +T{ +.na +.nh +.BR gelf_newphdr () +T} Thread safety MT-Safe +.TE + +.SH REPORTING BUGS +Report bugs to or https://sourceware.org/bugzilla/.