]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
doc: Add gelf_newphdr.3
authorAaron Merey <amerey@redhat.com>
Tue, 28 Oct 2025 22:26:31 +0000 (18:26 -0400)
committerAaron Merey <amerey@redhat.com>
Tue, 28 Oct 2025 22:26:31 +0000 (18:26 -0400)
Signed-off-by: Aaron Merey <amerey@redhat.com>
doc/Makefile.am
doc/gelf_newphdr.3 [new file with mode: 0644]

index d8bbca5527c9be644d16af9126f8ae2996649467..db566bcef3cc2fc9ddc47efdc97dd1f91f404a06 100644 (file)
@@ -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 (file)
index 0000000..a94697c
--- /dev/null
@@ -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 <gelf.h>
+
+.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 <elfutils-devel@sourceware.org> or https://sourceware.org/bugzilla/.