1 .\" $NetBSD: elf_getdata.3,v 1.2 2014/03/09 16:58:04 christos Exp $
3 .\" Copyright (c) 2006,2008,2010-2011 Joseph Koshy. All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
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.
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
26 .\" Id: elf_getdata.3 1766 2011-08-22 06:01:03Z jkoshy
35 .Nd iterate through or allocate section data
41 .Fn elf_getdata "Elf_Scn *scn" "Elf_Data *data"
43 .Fn elf_newdata "Elf_Scn *scn"
45 .Fn elf_rawdata "Elf_Scn *scn" "Elf_Data *data"
47 These functions are used to access and manipulate data descriptors
48 associated with section descriptors.
49 Data descriptors used by the ELF library are described in
54 will return the next data descriptor associated with section descriptor
56 The returned data descriptor will be setup to contain translated data.
61 in which case the function returns the first data descriptor
62 associated with section
68 it must be a pointer to a data descriptor associated with
73 will return a pointer to the next data descriptor for the section,
76 when the end of the section's descriptor list is reached.
80 will allocate a new data descriptor and append it to the list of data
81 descriptors associated with section descriptor
83 The new data descriptor will be initialized as follows:
84 .Bl -tag -width "d_version" -compact -offset indent
92 This field is under application control if the
94 flag was set on the ELF descriptor.
101 Set to the current working version of the library, as set by
104 The application must set these values as appropriate before
109 must be associated with an ELF file opened for writing.
110 If the application has not requested full control of layout by
115 then the data referenced by the returned descriptor will be positioned
116 after the existing content of the section, honoring the file alignment
119 On successful completion of a call to
121 the ELF library will mark the section
128 is used to step through the data descriptors associated with
131 In contrast to function
133 this function returns untranslated data.
138 the first data descriptor associated with section
145 is must be a data descriptor associated with
150 will return the next data descriptor in the list, or
152 if no further descriptors are present.
159 .Ss Special handling of zero-sized and SHT_NOBITS sections
162 and for zero-sized sections,
167 return a pointer to a valid
169 structure that has its
175 member set to the size of the section.
177 If an application wishes to create a section of type
179 it should add a data buffer to the section using function
181 It should then set the
185 members of the returned
189 and the desired size of the section respectively.
191 These functions return a valid pointer to a data descriptor if successful, or
195 These functions may fail with the following errors:
196 .Bl -tag -width "[ELF_E_RESOURCE]"
197 .It Bq Er ELF_E_ARGUMENT
198 Either of the arguments
204 .It Bq Er ELF_E_ARGUMENT
205 The data descriptor referenced by argument
207 is not associated with section descriptor
209 .It Bq Er ELF_E_ARGUMENT
210 The section denoted by argument
212 had no data associated with it.
214 Retrieval of data from the underlying object failed.
215 .It Bq Er ELF_E_RESOURCE
216 An out of memory condition was detected.
217 .It Bq Er ELF_E_SECTION
222 .It Bq Er ELF_E_SECTION
223 The type of the section
225 was not recognized by the library.
226 .It Bq Er ELF_E_SECTION
227 The size of the section
229 is not a multiple of the file size for its section type.
230 .It Bq Er ELF_E_SECTION
231 The file offset for section
234 .It Bq Er ELF_E_UNIMPL
235 The section type associated with section
237 is currently unsupported by the library.