Manpage logo

elf_strptr - Return a pointer to a string in a string table section

NAME  SYNOPSIS  DESCRIPTION  PARAMETERS  RETURN VALUE  SEE ALSO  ATTRIBUTES  REPORTING BUGS 

NAME

elf_strptr − 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

REPORTING BUGS

Report bugs to <[email protected]> or https://sourceware.org/bugzilla/.


Updated 2026-06-01 - jenkler.se | uex.se