1 .\" Copyright (c) 2006-2008 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 retrieve or allocate the object file header
39 .Fn elf32_newehdr "Elf *elf"
41 .Fn elf64_newehdr "Elf *elf"
44 .Fn gelf_newehdr "Elf *elf" "int elfclass"
46 These functions retrieve the ELF header from the ELF descriptor
48 allocating a new header if needed.
49 File data structures are translated to their in-memory representations
55 returns a pointer to a 32 bit
60 returns a pointer to a 64 bit
61 .Vt Elf64_Ehdr structure.
69 returns the value returned by
70 .Fn elf32_newehdr "elf" .
75 it returns the value returned by
76 .Fn elf64_newehdr "elf" .
78 If a fresh header structure is allocated, the members of the
79 structure are initialized as follows:
80 .Bl -tag -width indent
81 .It Va "e_ident[EI_MAG0..EI_MAG3]"
82 Identification bytes at offsets
88 are set to the ELF signature.
89 .It Va "e_ident[EI_CLASS]"
90 The identification byte at offset
92 is set to the ELF class associated with the function being called
97 .It Va "e_ident[EI_DATA]"
98 The identification byte at offset
102 .It Va "e_ident[EI_VERSION]"
103 The identification byte at offset
105 is set to the ELF library's operating version set by a prior call to
114 is set to the ELF library's operating version set by a prior call to
118 Other members of the header are set to zero.
119 The application is responsible for changing these values
120 as needed before calling
123 If successful, these three functions set the
125 flag on ELF descriptor
128 These functions return a pointer to a translated header descriptor
129 if successful, or NULL on failure.
131 These functions can fail with the following errors:
132 .Bl -tag -width "[ELF_E_RESOURCE]"
133 .It Bq Er ELF_E_ARGUMENT
137 .It Bq Er ELF_E_ARGUMENT
140 was not a descriptor for an ELF object.
141 .It Bq Er ELF_E_ARGUMENT
144 had an unsupported value.
145 .It Bq Er ELF_E_ARGUMENT
146 The class of the ELF descriptor
148 did not match that of the requested operation.
149 .It Bq Er ELF_E_ARGUMENT
152 the class of argument
156 and did not match the argument
158 .It Bq Er ELF_E_CLASS
159 The ELF class of descriptor
161 did not match that of the API function being called.
162 .It Bq Er ELF_E_HEADER
163 A malformed ELF header was detected.
164 .It Bq Er ELF_E_RESOURCE
165 An out of memory condition was detected during execution.
166 .It Bq Er ELF_E_SECTION
167 The ELF descriptor in argument
169 did not adhere to the conventions used for extended numbering.
170 .It Bq Er ELF_E_VERSION
173 had an unsupported ELF version number.
177 .Xr elf32_getehdr 3 ,
178 .Xr elf64_getehdr 3 ,