elf_newscn - Man Page
create a new section for an ELF descriptor
Synopsis
#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 zero-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 | MT-Safe |
Reporting Bugs
Report bugs to <elfutils-devel@sourceware.org> or https://sourceware.org/bugzilla/.
Referenced By
elf_newdata(3), elf_nextscn(3).