GELF_NEWPHDR(3) Libelf Programmer's Manual GELF_NEWPHDR(3) NAME gelf_newphdr - allocate and initialize a new program header table SYNOPSIS #include void *gelf_newphdr(Elf *elf, size_t phnum); DESCRIPTION gelf_newphdr() creates a new program header table with phnum entries for the ELF descriptor elf, zeroing all entries. If a program header table al- ready exists for elf, it is discarded. If phnum is zero, any existing pro- gram header table is removed. This array is maintained within the ELF descriptor and must not be freed directly. After calling 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. PARAMETERS elf Pointer to an ELF descriptor of kind ELF_K_ELF. phnum Number of entries in the new program header table. If zero, any ex- isting program header table is removed. RETURN VALUE On success, returns a non-NULL void pointer to the new program header ta- ble. The new program header table can be retrieved as a GElf_Phdr * using gelf_getphdr(). elf32_getphdr() or elf64_getphdr() can also be used de- pending on the class of elf. If 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 elf is NULL, then NULL is returned without set- ting elf_errno. Other libelf implementations of gelf_newphdr() may use a different return type. SEE ALSO gelf_getphdr(3), gelf_update_phdr(3), libelf(3), elf(5) ATTRIBUTES allbox; lbx lb lb l l l. Interface Attribute Value T{ gelf_newphdr() T} Thread safety MT-Safe REPORTING BUGS Report bugs to or https://source- ware.org/bugzilla/. Libelf 2025-09-23 GELF_NEWPHDR(3)