elf_newscn3
Create a new section for an elf descriptor
Usage
#include <libelf.h> Elf_Scn *elf_newscn(Elf * elf");"
Overview
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.
Attributes
| Interface | Attribute | Value |
| elf_newscn() | Thread safety | MT-Safe |