GELF_UPDATE_SYMSHNDX(3)

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_getscn(3), and 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

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_getscn(3), elf_scnshndx(3), gelf_fsize(3), gelf_getsymshndx(3), gelf_update_sym(3), libelf(3), elf(5)

ATTRIBUTES
Interface | Attribute | Value
 | Thread safety | MT-Safe

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