---
name: "elf_getshdrstrndx"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/elf_getshdrstrndx"
---

# elf\_getshdrstrndx(3)

retrieve the index of the section name string table

## NAME

**elf\_getshdrstrndx** – retrieve the index of the section name string table

## LIBRARY

library “libelf”

## SYNOPSIS

**#include \<libelf.h\>**

*int*\

**elf\_getshdrstrndx**(*Elf \*elf*, *size\_t \*ndxptr*);

## DESCRIPTION

Function **elf\_getshdrstrndx**() retrieves the section index of the string table containing section names from descriptor *elf* and stores it into the location pointed to by argument *ndxptr*.

This function allow applications to process both normal ELF objects and ELF objects that use extended section numbering uniformly.

## RETURN VALUES

These functions return zero if successful, or -1 in case of an error.

## ERRORS

These functions can fail with the following errors:

- \[ELF\_E\_ARGUMENT\]

  A NULL value was passed in for argument *elf*.

- \[ELF\_E\_ARGUMENT\]

  Argument *elf* was not for an ELF file.

- \[ELF\_E\_ARGUMENT\]

  Argument *elf* lacks an ELF Executable header.

- \[ELF\_E\_ARGUMENT\]

  Argument *ndx* contained a value in the reserved range of section indices.

## SEE ALSO

[elf(3)](/elf/3.md), [elf32\_getehdr(3)](/elf32_getehdr/3.md), [elf64\_getehdr(3)](/elf64_getehdr/3.md), [elf\_getident(3)](/elf_getident/3.md), [elf\_getphdrnum(3)](/elf_getphdrnum/3.md), [elf\_getshdrnum(3)](/elf_getshdrnum/3.md), [gelf(3)](/gelf/3.md), [gelf\_getehdr(3)](/gelf_getehdr/3.md)
