---
name: "elf_getshstrndx"
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_getshstrndx"
---

# elf\_getshstrndx(3)

retrieve/update the index of the section name string table

## NAME

**elf\_getshstrndx**, **elf\_setshstrndx** – retrieve/update the index of the section name string table

## LIBRARY

library “libelf”

## SYNOPSIS

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

*int*\

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

*int*\

**elf\_setshstrndx**(*Elf \*elf*, *size\_t ndx*);

## DESCRIPTION

Function **elf\_getshstrndx**() is deprecated. Please use [elf\_getshdrstrndx(3)](/elf_getshdrstrndx/3.md) instead.

Function **elf\_getshstrndx**() 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*.

Function **elf\_setshstrndx**() sets the index of the section name string table to argument *ndx*.

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

## RETURN VALUES

These functions return a non-zero value if successful, or zero 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)
