---
name: "elf_strptr"
section: "3"
platform: "linux"
package: "libelf"
version: "0.197-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/elf_strptr"
---

# elf\_strptr(3)

Return a pointer to a string in a string table section

## 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/3.md), [**elf\_getscn**(3)](/elf_getscn/3.md), [**libelf**(3)](/libelf/3.md), [**elf**(5)](/elf/5.md)

## ATTRIBUTES

| | | |
| --- | --- | --- |
| **Interface** | **Attribute** | **Value** |
| **elf\_strptr**() | Thread safety | MT-Safe |

## REPORTING BUGS

Report bugs to \<elfutils-devel@sourceware.org\> or https://sourceware.org/bugzilla/.
