gelf_update_symshndx3
Update class-independent symbol information and extended section index in symbol table
Usage
#include <gelf.h> int gelf_update_symshndx (Elf_Data *symdata, Elf_Data *shndxdata, int ndx, GElf_Sym *sym, Elf32_Word xshndx);
Overview
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_Datafor a section with typeSHT_SYMTABorSHT_DYNSYM.
- shndxdata
-
Pointer to
Elf_Datafor a section with typeSHT_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
ELFCLASS32binaries,st_valueandst_sizeshould 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_XINDEXthen xshndx should beSHN_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.
Attributes
| Interface | Attribute | Value |
| gelf_update_symshndx() | Thread safety | MT-Safe |