elf_getshdrnum3
Retrieve the number of section headers in an elf file
Usage
#include <libelf.h>
int elf_getshdrnum("Elf *elf", size_t *dst );
int elf_getshnum("Elf *elf", size_t *dst ); (deprecated)
Overview
The elf_getshdrnum() function stores the number of section headers (sections) associated with the ELF descriptor elf into the variable pointed to by dst.
It transparently handles both standard and extended section header counts. If the number of section headers exceeds the representable range of the e_shnum field in the ELF header, the ELF specification allows encoding the true count in section header 0’s sh_size field, and sets e_shnum to 0. This function transparently handles that case.
The function elf_getshnum() is a deprecated alias for elf_getshdrnum() and should not be used in new code (see HISTORY).
Parameters
- elf
-
A pointer to an
Elfdescriptor opened with elf_begin(3). The descriptor must represent a file of kind ELF_K_ELF . If NULL, the function returns -1 without setting elf_errno.
- dst
-
Pointer to a
size_tvariable. On success, the number of section headers is written here. Must not be NULL.
Return value
Returns 0 on success and stores the result in dst. Returns -1 on failure.
Attributes
| Interface | Attribute | Value |
| elf_getshdrnum(), elf_getshnum() | Thread safety | MT-Safe |