GELF\_UPDATE\_SYMSHNDX(3) Libelf Programmer's Manual GELF\_UPDATE\_SYMSHNDX(3)

# [NAME](#NAME)

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

# [SYNOPSIS](#SYNOPSIS)

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

# [DESCRIPTION](#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-&gt;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)](/man/os/elfutils/elf_scnshndx.3), [**elf\_getscn**(3)](/man/os/elfutils/elf_getscn.3), and [**elf\_getdata**(3)](/man/os/elfutils/elf_getdata.3). 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](#PARAMETERS)

[*symdata*](#symdata)

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

[*shndxdata*](#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*](#ndx)

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

[*sym*](#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*](#xshndx)

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

# [RETURN VALUE](#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](#SEE_ALSO)

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

# [ATTRIBUTES](#ATTRIBUTES)

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

# [REPORTING BUGS](#REPORTING_BUGS)

Report bugs to &lt;elfutils-devel@sourceware.org&gt; or https://sourceware.org/bugzilla/.

2025-12-30 Libelf

---

Document: gelf_update_symshndx(3) from elfutils 0.196-r1 (Chainguard OS)
Source: https://sourceware.org/git/elfutils.git
