xref: /netbsd-src/external/bsd/elftoolchain/dist/libelf/gelf_getsym.3 (revision 5ac3bc719ce6e70593039505b491894133237d12)
1*5ac3bc71Schristos.\"	$NetBSD: gelf_getsym.3,v 1.6 2024/03/03 17:37:34 christos Exp $
2e81373b4Schristos.\"
39dd9d0cfSchristos.\" Copyright (c) 2006,2008 Joseph Koshy.  All rights reserved.
49dd9d0cfSchristos.\"
59dd9d0cfSchristos.\" Redistribution and use in source and binary forms, with or without
69dd9d0cfSchristos.\" modification, are permitted provided that the following conditions
79dd9d0cfSchristos.\" are met:
89dd9d0cfSchristos.\" 1. Redistributions of source code must retain the above copyright
99dd9d0cfSchristos.\"    notice, this list of conditions and the following disclaimer.
109dd9d0cfSchristos.\" 2. Redistributions in binary form must reproduce the above copyright
119dd9d0cfSchristos.\"    notice, this list of conditions and the following disclaimer in the
129dd9d0cfSchristos.\"    documentation and/or other materials provided with the distribution.
139dd9d0cfSchristos.\"
149dd9d0cfSchristos.\" This software is provided by Joseph Koshy ``as is'' and
159dd9d0cfSchristos.\" any express or implied warranties, including, but not limited to, the
169dd9d0cfSchristos.\" implied warranties of merchantability and fitness for a particular purpose
179dd9d0cfSchristos.\" are disclaimed.  in no event shall Joseph Koshy be liable
189dd9d0cfSchristos.\" for any direct, indirect, incidental, special, exemplary, or consequential
199dd9d0cfSchristos.\" damages (including, but not limited to, procurement of substitute goods
209dd9d0cfSchristos.\" or services; loss of use, data, or profits; or business interruption)
219dd9d0cfSchristos.\" however caused and on any theory of liability, whether in contract, strict
229dd9d0cfSchristos.\" liability, or tort (including negligence or otherwise) arising in any way
239dd9d0cfSchristos.\" out of the use of this software, even if advised of the possibility of
249dd9d0cfSchristos.\" such damage.
259dd9d0cfSchristos.\"
263f622274Sjkoshy.\" Id: gelf_getsym.3 3958 2022-03-12 14:31:32Z jkoshy
279dd9d0cfSchristos.\"
28c5261b83Sjkoshy.Dd April 22, 2019
299dd9d0cfSchristos.Dt GELF_GETSYM 3
30c5261b83Sjkoshy.Os
319dd9d0cfSchristos.Sh NAME
329dd9d0cfSchristos.Nm gelf_getsym ,
339dd9d0cfSchristos.Nm gelf_update_sym
349dd9d0cfSchristos.Nd read and update symbol information
359dd9d0cfSchristos.Sh LIBRARY
369dd9d0cfSchristos.Lb libelf
379dd9d0cfSchristos.Sh SYNOPSIS
389dd9d0cfSchristos.In gelf.h
399dd9d0cfSchristos.Ft "GElf_Sym *"
409dd9d0cfSchristos.Fn gelf_getsym "Elf_Data *data" "int ndx" "GElf_Sym *sym"
419dd9d0cfSchristos.Ft int
429dd9d0cfSchristos.Fn gelf_update_sym "Elf_Data *data" "int ndx" "GElf_Sym *sym"
439dd9d0cfSchristos.Sh DESCRIPTION
449dd9d0cfSchristosThese convenience functions are used to retrieve and update class-dependent
459dd9d0cfSchristos.Vt Elf32_Sym
469dd9d0cfSchristosand
479dd9d0cfSchristos.Vt Elf64_Sym
489dd9d0cfSchristosstructures in an ELF object.
499dd9d0cfSchristos.Pp
509dd9d0cfSchristosArgument
513f622274Sjkoshy.Fa data
529dd9d0cfSchristosis an
539dd9d0cfSchristos.Vt Elf_Data
549dd9d0cfSchristosdescriptor associated with a section of type
559dd9d0cfSchristos.Dv SHT_SYMTAB ,
569dd9d0cfSchristos.Dv SHT_DYNSYM
579dd9d0cfSchristosor
589dd9d0cfSchristos.Dv SHT_GNU_versym .
599dd9d0cfSchristosArgument
603f622274Sjkoshy.Fa ndx
619dd9d0cfSchristosis the index of the symbol being retrieved or updated.
629dd9d0cfSchristosThe class-independent
639dd9d0cfSchristos.Vt GElf_Sym
649dd9d0cfSchristosstructure is described in
659dd9d0cfSchristos.Xr gelf 3 .
669dd9d0cfSchristos.Pp
679dd9d0cfSchristosFunction
689dd9d0cfSchristos.Fn gelf_getsym
699dd9d0cfSchristosretrieves class-dependent symbol information at index
703f622274Sjkoshy.Fa ndx
719dd9d0cfSchristosin data buffer
723f622274Sjkoshy.Fa data
739dd9d0cfSchristosand copies it to the destination pointed to by argument
743f622274Sjkoshy.Fa sym
759dd9d0cfSchristosafter translation to class-independent form.
769dd9d0cfSchristos.Pp
779dd9d0cfSchristosFunction
789dd9d0cfSchristos.Fn gelf_update_sym
799dd9d0cfSchristosconverts the class-independent symbol information pointed to
809dd9d0cfSchristosby argument
813f622274Sjkoshy.Fa sym
829dd9d0cfSchristosto class-dependent form, and writes it to the symbol entry at index
833f622274Sjkoshy.Fa ndx
849dd9d0cfSchristosin the data buffer described by argument
853f622274Sjkoshy.Fa data .
869dd9d0cfSchristosFunction
879dd9d0cfSchristos.Fn gelf_update_sym
889dd9d0cfSchristossignals an error if any of the values in the class-independent
899dd9d0cfSchristosrepresentation exceeds the representable limits of the target
909dd9d0cfSchristostype.
919dd9d0cfSchristos.Sh RETURN VALUES
929dd9d0cfSchristosFunction
939dd9d0cfSchristos.Fn gelf_getsym
949dd9d0cfSchristosreturns the value of argument
953f622274Sjkoshy.Fa sym
96c5261b83Sjkoshyif successful, or
97c5261b83Sjkoshy.Dv NULL
98c5261b83Sjkoshyin case of an error.
999dd9d0cfSchristosFunction
1009dd9d0cfSchristos.Fn gelf_update_sym
1019dd9d0cfSchristosreturns a non-zero value if successful, or zero in case of an error.
1029dd9d0cfSchristos.Sh ERRORS
1039dd9d0cfSchristosThese functions may fail with the following errors:
1049dd9d0cfSchristos.Bl -tag -width "[ELF_E_RESOURCE]"
1059dd9d0cfSchristos.It Bq Er ELF_E_ARGUMENT
1069dd9d0cfSchristosArguments
1073f622274Sjkoshy.Fa data
1089dd9d0cfSchristosor
1093f622274Sjkoshy.Fa sym
110c5261b83Sjkoshywere
111c5261b83Sjkoshy.Dv NULL .
1129dd9d0cfSchristos.It Bq Er ELF_E_ARGUMENT
1139dd9d0cfSchristosArgument
1143f622274Sjkoshy.Fa ndx
1159dd9d0cfSchristoswas less than zero or larger than the number of symbols in the data
1169dd9d0cfSchristosdescriptor.
1179dd9d0cfSchristos.It Bq Er ELF_E_ARGUMENT
1189dd9d0cfSchristosData descriptor
1193f622274Sjkoshy.Fa data
1209dd9d0cfSchristoswas not associated with a section containing symbol information.
1219dd9d0cfSchristos.It Bq Er ELF_E_RANGE
1229dd9d0cfSchristosA value was not representable in the target type.
123c5261b83Sjkoshy.It Bq Er ELF_E_VERSION
124c5261b83SjkoshyThe
125c5261b83Sjkoshy.Vt Elf_Data
126c5261b83Sjkoshydescriptor denoted by argument
1273f622274Sjkoshy.Fa data
128c5261b83Sjkoshyis associated with an ELF object with an unsupported version.
1299dd9d0cfSchristos.El
1309dd9d0cfSchristos.Sh SEE ALSO
1319dd9d0cfSchristos.Xr elf 3 ,
1329dd9d0cfSchristos.Xr elf_getdata 3 ,
1339dd9d0cfSchristos.Xr elf_getscn 3 ,
1349dd9d0cfSchristos.Xr gelf 3 ,
1359dd9d0cfSchristos.Xr gelf_getsyminfo 3 ,
1369dd9d0cfSchristos.Xr gelf_update_syminfo 3
137