Signed-off-by: Aaron Merey <ame...@redhat.com> --- doc/Makefile.am | 1 + doc/elf_getphdrnum.3 | 74 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 doc/elf_getphdrnum.3
diff --git a/doc/Makefile.am b/doc/Makefile.am index d3fd9a49..5c1cd51e 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -68,6 +68,7 @@ notrans_dist_man3_MANS= elf32_checksum.3 \ elf_getdata.3 \ elf_getdata_rawchunk.3 \ elf_getident.3 \ + elf_getphdrnum.3 \ elf_getscn.3 \ elf_hash.3 \ elf_kind.3 \ diff --git a/doc/elf_getphdrnum.3 b/doc/elf_getphdrnum.3 new file mode 100644 index 00000000..f67899bd --- /dev/null +++ b/doc/elf_getphdrnum.3 @@ -0,0 +1,74 @@ +.TH ELF_GETPHDRNUM 3 2025-06-30 "Libelf" "Libelf Programmer's Manual" + +.SH NAME +elf_getphdrnum \- retrieve the number of program headers in an ELF file +.SH SYNOPSIS +.nf +#include <libelf.h> + +.B int elf_getphdrnum("Elf *elf", "size_t *dst"); +.fi +.SH DESCRIPTION +The +.BR elf_getphdrnum () +function stores the number of program headers associated with the ELF descriptor +.I elf +into the variable pointed to by +.IR dst . + +If the number of program headers exceeds the representable range of the +.I e_phnum +field in the ELF header, the ELF specification allows encoding the true count +in section header 0’s +.I sh_info +field, and sets +.I e_phnum +to the reserved value +.B PN_XNUM +(usually 0xFFFF). This function transparently handles that case. + +If no program headers are present, or if the ELF file has not yet been fully +initialized, the function may return 0 as the count. + +.SH PARAMETERS +.TP +.I elf +A pointer to an +.B Elf +descriptor. +The descriptor must represent a file with +.I Elf_Kind +.B ELF_K_ELF . + +.TP +.I dst +On success, the number of program headers in +.I elf +is written here. Must not be NULL. + +.SH RETURN VALUE +Returns 0 on success and stores the result in +.IR dst . +Returns \-1 on failure or if +.B elf +is NULL. + +.SH SEE ALSO +.BR libelf (3), +.BR elf (5) + +.SH ATTRIBUTES +.TS +allbox; +lbx lb lb +l l l. +Interface Attribute Value +T{ +.na +.nh +.BR elf_getphdrnum () +T} Thread safety MT-Safe +.TE + +.SH REPORTING BUGS +Report bugs to <elfutils-devel@sourceware.org> or https://sourceware.org/bugzilla/. -- 2.49.0