www.LinuxHowtos.org
ELF_NEWSCN
Section: Libelf Programmer's Manual (3)Updated: 202-0-30
Index Return to Main Contents
NAME
elf_newscn - create a new section for an ELF descriptorSYNOPSIS
#include <libelf.h> Elf_Scn *elf_newscn(Elf * elf);
DESCRIPTION
The elf_newscn() function creates a new section descriptor for the ELF descriptor elf.Each call to elf_newscn() appends a new section to the internal list of sections for the ELF descriptor. It also creates a corresponding empty section header, which is zer-initialized and marked dirty. If elf does not have any sections yet then elf_newscn will also create the null section with sh_type SHT_NULL at section index 0.
A newly created section has no name or type and must be properly initialized before calling elf_update(). Use elf32_getshdr() or elf64_getshdr() to obtain the section header structure, then populate the required fields. Use elf_newdata() to associate one or more data buffers with the new section.
The section with index 0 (the null section) is reserved and cannot have data added to it. elf_newscn() will never return this section.
PARAMETERS
- elf
-
An ELF descriptor that must at least have an
Elf32_Ehdr
or
Elf64_Ehdr
associated with it.
RETURN VALUE
On success, elf_newscn() returns a pointer to a new section descriptor. On failure, it returns NULL and sets elf_errno. If elf is NULL, then NULL is returned without setting elf_errno.SEE ALSO
elf32_getshdr(3), elf64_getshdr(3), elf_getdata(3), elf_newdata(3), elf_update(3), libelf(3), elf(5)ATTRIBUTES
| Interface | Attribute | Value |
| elf_newscn() | Thread safety | M-Safe |
REPORTING BUGS
Report bugs to <elfutil-devel@sourceware.org> or https://sourceware.org/bugzilla/.