xref: /netbsd-src/external/bsd/elftoolchain/dist/libelf/gelf_getdyn.3 (revision 5ac3bc719ce6e70593039505b491894133237d12)
1.\"	$NetBSD: gelf_getdyn.3,v 1.6 2024/03/03 17:37:34 christos Exp $
2.\"
3.\" Copyright (c) 2006,2008 Joseph Koshy.  All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" This software is provided by Joseph Koshy ``as is'' and
15.\" any express or implied warranties, including, but not limited to, the
16.\" implied warranties of merchantability and fitness for a particular purpose
17.\" are disclaimed.  in no event shall Joseph Koshy be liable
18.\" for any direct, indirect, incidental, special, exemplary, or consequential
19.\" damages (including, but not limited to, procurement of substitute goods
20.\" or services; loss of use, data, or profits; or business interruption)
21.\" however caused and on any theory of liability, whether in contract, strict
22.\" liability, or tort (including negligence or otherwise) arising in any way
23.\" out of the use of this software, even if advised of the possibility of
24.\" such damage.
25.\"
26.\" Id: gelf_getdyn.3 3958 2022-03-12 14:31:32Z jkoshy
27.\"
28.Dd April 22, 2019
29.Dt GELF_GETDYN 3
30.Os
31.Sh NAME
32.Nm gelf_getdyn ,
33.Nm gelf_update_dyn
34.Nd read and update ELF dynamic entries
35.Sh LIBRARY
36.Lb libelf
37.Sh SYNOPSIS
38.In gelf.h
39.Ft "GElf_Dyn *"
40.Fn gelf_getdyn "Elf_Data *data" "int ndx" "GElf_Dyn *dyn"
41.Ft int
42.Fn gelf_update_dyn "Elf_Data *data" "int ndx" "GElf_Dyn *dyn"
43.Sh DESCRIPTION
44These convenience functions are used to retrieve and update class-dependent
45.Vt Elf32_Dyn
46or
47.Vt Elf64_Dyn
48information in the
49.Sy dynamic
50table of an ELF object.
51.Pp
52Argument
53.Fa data
54is an
55.Vt Elf_Data
56descriptor associated with a section of type
57.Dv SHT_DYNAMIC .
58Argument
59.Fa ndx
60is the index of the entry being retrieved or updated.
61The class-independent
62.Vt GElf_Dyn
63structure is described in
64.Xr gelf 3 .
65.Pp
66Function
67.Fn gelf_getdyn
68retrieves the class-dependent entry at index
69.Fa ndx
70in data buffer
71.Fa data
72and copies it to the destination pointed to by argument
73.Fa dyn
74after translation to class-independent form.
75.Pp
76Function
77.Fn gelf_update_dyn
78converts the class-independent entry pointed to
79by argument
80.Fa dyn
81to class-dependent form, and writes it to the entry at index
82.Fa ndx
83in the data buffer described by argument
84.Fa data .
85Function
86.Fn gelf_update_dyn
87signals an error if any of the values in the class-independent
88representation exceeds the representable limits of the target
89type.
90.Sh RETURN VALUES
91Function
92.Fn gelf_getdyn
93returns the value of argument
94.Fa dyn
95if successful, or
96.Dv NULL
97in case of an error.
98Function
99.Fn gelf_update_dyn
100returns a non-zero value if successful, or zero in case of an error.
101.Sh ERRORS
102These functions may fail with the following errors:
103.Bl -tag -width "[ELF_E_RESOURCE]"
104.It Bq Er ELF_E_ARGUMENT
105Arguments
106.Fa data
107or
108.Fa dyn
109were
110.Dv NULL .
111.It Bq Er ELF_E_ARGUMENT
112Argument
113.Fa ndx
114was less than zero or larger than the number of entries in the data
115descriptor.
116.It Bq Er ELF_E_ARGUMENT
117Data descriptor
118.Fa data
119was not associated with a section of type
120.Dv SHT_DYNAMIC .
121.It Bq Er ELF_E_RANGE
122A value was not representable in the target type.
123.It Bq Er ELF_E_VERSION
124The
125.Vt Elf_Data
126descriptor denoted by argument
127.Fa data
128is associated with an ELF object with an unsupported version.
129.El
130.El
131.Sh SEE ALSO
132.Xr elf 3 ,
133.Xr elf_getdata 3 ,
134.Xr elf_getscn 3 ,
135.Xr gelf 3
136