ELF32_NEWPHDR(3)
β¨ ELF32_NEWP HDR β wait, ELF32_NEWPHDR(3) β¨
okay bestie so this is a page from the Libelf Programmer's Manual, and it's all about elf32_newphdr and elf64_newphdr β the little functions that build you a whole new program header table for a 32-bit or 64-bit ELF object file. like, out with the old table, in with the new. π
πΈ NAME πΈ
elf32_newphdr, elf64_newphdr β create a new program header table for a 32-bit or 64-bit ELF object file
π SYNOPSIS π
#include <libelf.h>
Elf32_Phdr *elf32_newphdr(Elf *elf, size_t count);
Elf64_Phdr *elf64_newphdr(Elf *elf, size_t count);
π DESCRIPTION π
okay so the whole vibe here is: you're creating a brand new program header table for the ELF object file that elf points at. the number of entries in this fresh new table? that's what count is for. and listen β a count of zero straight-up removes the existing program header table. gone. deleted. not me being dramatic, that's literally what it does. π
what actually happens under the hood: the function allocates a new array of Elf32_Phdr and makes it the program header table for elf. the new program header contents get set to zero, and any previous program header table is discarded β like, it's not coming back. π«Ά
β οΈ important bestie: an ELF header must exist before creating a program header table. don't skip that step, the vibe check will fail.
π PARAMETERS π
elfβ pointer to the ELF object you want a new program header table created for. that's the target. the main character, if you will. πcountβ how many entries the new program header table has. and fr fr, acountof zero removes the existing program header table.
β RETURN VALUE β
- on success, it returns a pointer to the first
Elf32_Phdrin the newly created program header table. slay. β¨ - if
elfisNULL, then it returnsNULL. that's it, that's the deal. - if an error occurs, it returns
NULLand sets a libelf error code. so checkelf_errno(3)if you're confused, bestie.
π¦ SEE ALSO π¦
π ATTRIBUTES π
for an explanation of the terms used in this section, see attributes(7).
elf32_newphdr(),elf64_newphdr()β Thread safety:MT-Safeπ₯
(the original had this in a cute little table, but tables aren't the vibe here β same facts though, no cap.)
π REPORTING BUGS π
found a bug? don't gatekeep it, report it to <elfutils-devel@sourceware.org> or hit up https://sourceware.org/bugzilla/. the maintainers wanna know. π
and that's the whole page, bestie π this was Libelf, dated 2024-08-14 β ELF32_NEWPHDR(3), icon of building program header tables from scratch. periodt. π
β¨
π¦ where this page comes from
- alpine 3.22: elfutils-doc 0.193-r0 Β· GPL-3.0-or-later AND ( GPL-2.0-or-later OR LGPL-3.0-or-later )
- alpine 3.23: elfutils-doc 0.194-r0 Β· GPL-3.0-or-later AND ( GPL-2.0-or-later OR LGPL-3.0-or-later )
- alpine 3.24: elfutils-doc 0.195-r0 Β· GPL-3.0-or-later AND ( GPL-2.0-or-later OR LGPL-3.0-or-later )
- arch rolling: libelf 0.196-1
- arch rolling: libelf 0.197-1 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- centos-stream 10: elfutils-libelf-devel 0.197-1.el10 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- centos-stream 9: elfutils-libelf-devel 0.197-1.el9 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- centos-stream 9: elfutils-libelf-devel 0.197-1.el9 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- debian trixie: libelf-dev 0.192-4 Β· GPL-3.0-or-later
- fedora 43: elfutils-libelf-devel 0.193-3.fc43 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 43: elfutils-libelf-devel 0.193-3.fc43 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 43: elfutils-libelf-devel 0.196-1.fc43
- fedora 43: elfutils-libelf-devel 0.196-1.fc43
- fedora 43: elfutils-libelf-devel 0.197-1.fc43 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 43: elfutils-libelf-devel 0.197-1.fc43 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 44: elfutils-libelf-devel 0.194-5.fc44 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 44: elfutils-libelf-devel 0.194-5.fc44 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 44: elfutils-libelf-devel 0.196-1.fc44
- fedora 44: elfutils-libelf-devel 0.196-1.fc44
- fedora 44: elfutils-libelf-devel 0.197-1.fc44 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 44: elfutils-libelf-devel 0.197-1.fc44 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- nixos 26.05: elfutils 0.194
- nixpkgs unstable: elfutils 0.195
- opensuse-leap 16.0: libelf-devel 0.192-160000.3.1 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- opensuse-leap 16.0: libelf-devel 0.192-160000.3.1 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- opensuse-leap 16.0: libelf-devel 0.192-160000.3.1 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- opensuse-leap 16.0: libelf-devel 0.192-160000.3.1 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- ubuntu questing: libelf-dev 0.193-1
- ubuntu resolute: libelf-dev 0.194-4 Β· GPL-3.0-or-later
- ubuntu stonking: libelf-dev 0.196-1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms