ELF_NEWDATA(3)
β¨ ELF_NEWDATA(3) β¨
okay bestie, welcome to the Libelf Programmer's Manual π this is elf_newdata, and she's here to hand you a fresh blank canvas for your ELF sections. let's go π«Ά
πΈ NAME πΈ
elf_newdata β add a new Elf_Data descriptor to a section. that's it, that's the job π
π¦ SYNOPSIS π¦
#include <libelf.h>
Elf_Data * elf_newdata(Elf_Scn *scn);
β¨ DESCRIPTION β¨
so elf_newdata() does the cute thing: it creates a brand-new Elf_Data descriptor and associates it with the section that scn points to. this descriptor is literally your tool for describing new section contents for an ELF object that's being constructed or modified. main character energy π₯
okay important, listen up π: the section must not be the null section (index 0). like, that one's off limits, no cap.
if the section has no data associated with it yet, or it was created using elf_newscn(), then this function creates the first Elf_Data descriptor for the section. slay, first one's free π
and then? every subsequent call to elf_newdata() will append new data descriptors to the section. so you can just keep stacking them, one after another, like charms on a bracelet π
the returned descriptor is marked dirty so that it will be included during elf_update(). (dirty here means "please write me out", not "unhinged", ok? she's included, she's committed π
)
and the returned descriptor is also initialized to represent no data, with:
d_bufset toNULLd_typeset toELF_T_BYTEd_versionset toEV_CURRENTd_sizeset to zerod_offset to zerod_alignset to one
so basically it's a blank template with vibes and zero content. you fill her in π¦
π PARAMETERS π
scnβ a section descriptor that the new data descriptor should be attached to. must not be section zero, the null section. and ifscnisNULL, this function returnsNULL. rude, but fair π
π RETURN VALUE π
on success: a pointer to a new, writable Elf_Data descriptor is returned. icon β¨
on failure: NULL is returned and elf_errno is set. π
if scn is NULL: then NULL is returned and elf_errno is not set. (no tea, no shade, no errno π)
the caller is responsible for configuring the return value (peep DESCRIPTION for the default field values, bestie β that's the checklist you're filling in).
π SEE ALSO π
go read those too, iykyk π§
β ATTRIBUTES β
- Interface:
elf_newdata() - Attribute: Thread safety
- Value:
MT-Safe
so you can call her from multiple threads at once, no problem π
π REPORTING BUGS π
found a bug? tell the devs, not me, bestie π report bugs to <elfutils-devel@sourceware.org> or at https://sourceware.org/bugzilla/.
okay that's the whole page!! π
she's from Libelf, dated 2025-06-30, and yes this is ELF_NEWDATA(3) β you ate, go write some sections π«ΆπΈβ¨
π¦ where this page comes from
- 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
- 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.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
- nixpkgs unstable: elfutils 0.195
- 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