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

# gelf\_update\_symshndx(3)

Update class-independent symbol information and extended section index in symbol table

## NAME

gelf\_update\_symshndx - Update class-independent symbol information and extended section index in symbol table

## SYNOPSIS

```
#include <gelf.h>
int gelf_update_symshndx (Elf_Data *symdata, Elf_Data *shndxdata, int ndx, GElf_Sym *sym, Elf32_Word xshndx);
```

## DESCRIPTION

This function updates *symdata* and *shndxdata*, at index *ndx* with the class-independent symbol information from *sym* and the section index *xshndx*. *symdata* should be an **Elf\_Data** pointer for an **SHT\_SYMTAB** or **SHT\_DYNSYM** section and *shndxdata* should be an **Elf\_Data** pointer for an **SHT\_SYMTAB\_SHNDX** section.

The number of symbols in the symbol table can be calculated by dividing the size of *symdata* by the size of a symbol table entry. The size of *symdata* can be obtained from *symdata-\>d\_size* or from the corresponding section header's **sh\_size**. The size of a symbol table entry can be obtained from **gelf\_fsize**() with **ELF\_T\_SYM** or from the corresponding section header's **sh\_entsize**.

A **SHT\_SYMTAB\_SHNDX** section is present in ELF binaries when the number of sections is too large to be represented as an unsigned 16-bit value.  In this case the **st\_shndx** field of a **GElf\_Sym** will be set to **SHN\_XINDEX** to indicate that the symbol's section index can be found in the **SHT\_SYMTAB\_SHNDX** section. *shndxdata* for this section can be acquired using [**elf\_scnshndx**(3)](/elf_scnshndx/3.md), [**elf\_getscn**(3)](/elf_getscn/3.md), and [**elf\_getdata**(3)](/elf_getdata/3.md). The number of entries in *shndxdata* must be equal to the number of entries in *symdata*. Entry *ndx* in *shndxdata* corresponds to entry *ndx* in *symdata*.

## PARAMETERS

- *symdata*

  Pointer to **Elf\_Data** for a section with type **SHT\_SYMTAB** or **SHT\_DYNSYM**.

- *shndxdata*

  Pointer to **Elf\_Data** for a section with type **SHT\_SYMTAB\_SHNDX**. *shndxdata* may be NULL.  If *shndxdata* is NULL, then *xshndx* must be zero.

- *ndx*

  Zero-based index of the symbol table entry and extended section index entry to be updated.

- *sym*

  Pointer to a caller-provided symbol table entry.  For **ELFCLASS32** binaries, **st\_value** and **st\_size** should be able to fit within unsigned 32-bit values. *sym* must not be NULL.

- *xshndx*

  Updated extended section index entry to be associated with *sym*. Must be zero if *shndxdata* is NULL.  If *sym-\>st\_shndx* is not **SHN\_XINDEX** then *xshndx* should be **SHN\_UNDEF**.

## RETURN VALUE

On success, a non-zero value is returned and the entries at index *ndx* in *symdata* and *shndxdata* (if not NULL) are updated with *sym* and *xshndx*, respectively.  The sections associated with *symdata* and *shndxdata* are flagged with **ELF\_F\_DIRTY**. On failure, zero is returned, elf\_errno is set.  If *sym* is NULL, then NULL is returned without setting elf\_errno.

## SEE ALSO

[**elf\_getdata**(3)](/elf_getdata/3.md), [**elf\_getscn**(3)](/elf_getscn/3.md), [**elf\_scnshndx**(3)](/elf_scnshndx/3.md), [**gelf\_fsize**(3)](/gelf_fsize/3.md), [**gelf\_getsymshndx**(3)](/gelf_getsymshndx/3.md), [**gelf\_update\_sym**(3)](/gelf_update_sym/3.md), [**libelf**(3)](/libelf/3.md), [**elf**(5)](/elf/5.md)

## ATTRIBUTES

| | | |
| --- | --- | --- |
| **Interface** | **Attribute** | **Value** |
| **gelf\_update\_symshndx**() | Thread safety | MT-Safe |

## REPORTING BUGS

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