elf_strptr - Man Page
Return a pointer to a string in a string table section
Synopsis
#include <libelf.h> char *elf_strptr(Elf *elf, size_t section_index, size_t offset);
Description
The elf_strptr() function returns a pointer to a null-terminated string located at offset bytes from the beginning of the string table section identified by section_index. The section must be of type SHT_STRTAB.
This function validates the provided offset against the size of the string table and ensures the string is null-terminated. It transparently handles both uncompressed and compressed sections.
If the ELF descriptor is not backed by memory mapping, or the section has not been loaded yet, the function will read and initialize the necessary data from the file.
Parameters
- elf
Pointer to an ELF descriptor.
- section_index
The index of the string table section (of type SHT_STRTAB).
- offset
The byte offset from the beginning of the string table section where the desired string is located.
Return Value
Returns a pointer to the string within the string table if successful. Returns NULL on error.
See Also
elf(3), elf_getscn(3), libelf(3), elf(5)
Attributes
| Interface | Attribute | Value |
|---|---|---|
| elf_strptr() | Thread safety | MT-Safe |
Reporting Bugs
Report bugs to <elfutils-devel@sourceware.org> or https://sourceware.org/bugzilla/.