1 .\" Copyright (c) 2006,2008,2010-2011 Joseph Koshy. All rights reserved.
3 .\" Redistribution and use in source and binary forms, with or without
4 .\" modification, are permitted provided that the following conditions
6 .\" 1. Redistributions of source code must retain the above copyright
7 .\" notice, this list of conditions and the following disclaimer.
8 .\" 2. Redistributions in binary form must reproduce the above copyright
9 .\" notice, this list of conditions and the following disclaimer in the
10 .\" documentation and/or other materials provided with the distribution.
12 .\" This software is provided by Joseph Koshy ``as is'' and
13 .\" any express or implied warranties, including, but not limited to, the
14 .\" implied warranties of merchantability and fitness for a particular purpose
15 .\" are disclaimed. in no event shall Joseph Koshy be liable
16 .\" for any direct, indirect, incidental, special, exemplary, or consequential
17 .\" damages (including, but not limited to, procurement of substitute goods
18 .\" or services; loss of use, data, or profits; or business interruption)
19 .\" however caused and on any theory of liability, whether in contract, strict
20 .\" liability, or tort (including negligence or otherwise) arising in any way
21 .\" out of the use of this software, even if advised of the possibility of
33 .Nd iterate through or allocate section data
39 .Fn elf_getdata "Elf_Scn *scn" "Elf_Data *data"
41 .Fn elf_newdata "Elf_Scn *scn"
43 .Fn elf_rawdata "Elf_Scn *scn" "Elf_Data *data"
45 These functions are used to access and manipulate data descriptors
46 associated with section descriptors.
47 Data descriptors used by the ELF library are described in
52 will return the next data descriptor associated with section descriptor
54 The returned data descriptor will be setup to contain translated data.
57 may be NULL, in which case the function returns the first data descriptor
58 associated with section
62 is not NULL, it must be a pointer to a data descriptor associated with
67 will return a pointer to the next data descriptor for the section,
68 or NULL when the end of the section's descriptor list is reached.
72 will allocate a new data descriptor and append it to the list of data
73 descriptors associated with section descriptor
75 The new data descriptor will be initialized as follows:
76 .Bl -tag -width "d_version" -compact -offset indent
83 This field is under application control if the
85 flag was set on the ELF descriptor.
92 Set to the current working version of the library, as set by
95 The application must set these values as appropriate before
100 must be associated with an ELF file opened for writing.
101 If the application has not requested full control of layout by
106 then the data referenced by the returned descriptor will be positioned
107 after the existing content of the section, honoring the file alignment
110 On successful completion of a call to
112 the ELF library will mark the section
119 is used to step through the data descriptors associated with
122 In contrast to function
124 this function returns untranslated data.
127 is NULL, the first data descriptor associated with section
132 is not NULL, is must be a data descriptor associated with
137 will return the next data descriptor in the list, or NULL
138 if no further descriptors are present.
145 .Ss Special handling of zero-sized and SHT_NOBITS sections
148 and for zero-sized sections,
153 return a pointer to a valid
155 structure that has its
157 member set to NULL and its
159 member set to the size of the section.
161 If an application wishes to create a section of type
163 it should add a data buffer to the section using function
165 It should then set the
169 members of the returned
171 structure to NULL and the desired size of the section respectively.
173 These functions return a valid pointer to a data descriptor if successful, or
174 NULL if an error occurs.
176 These functions may fail with the following errors:
177 .Bl -tag -width "[ELF_E_RESOURCE]"
178 .It Bq Er ELF_E_ARGUMENT
184 .It Bq Er ELF_E_ARGUMENT
185 The data descriptor referenced by argument
187 is not associated with section descriptor
189 .It Bq Er ELF_E_ARGUMENT
190 The section denoted by argument
192 had no data associated with it.
194 Retrieval of data from the underlying object failed.
195 .It Bq Er ELF_E_RESOURCE
196 An out of memory condition was detected.
197 .It Bq Er ELF_E_SECTION
198 The section type associated with section
200 is not recognized by the library.
201 .It Bq Er ELF_E_SECTION
202 The size of the section
204 is not a multiple of the file size for its section type.
205 .It Bq Er ELF_E_SECTION
206 The file offset for section
209 .It Bq Er ELF_E_UNIMPL
210 The section type associated with section
212 is currently unsupported by the library.