1 .\" $NetBSD: gelf_newehdr.3,v 1.2 2014/03/09 16:58:04 christos Exp $
3 .\" Copyright (c) 2006-2008 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: gelf_newehdr.3 189 2008-07-20 10:38:08Z jkoshy
35 .Nd retrieve or allocate the object file header
41 .Fn elf32_newehdr "Elf *elf"
43 .Fn elf64_newehdr "Elf *elf"
46 .Fn gelf_newehdr "Elf *elf" "int elfclass"
48 These functions retrieve the ELF header from the ELF descriptor
50 allocating a new header if needed.
51 File data structures are translated to their in-memory representations
57 returns a pointer to a 32 bit
62 returns a pointer to a 64 bit
63 .Vt Elf64_Ehdr structure.
71 returns the value returned by
72 .Fn elf32_newehdr "elf" .
77 it returns the value returned by
78 .Fn elf64_newehdr "elf" .
80 If a fresh header structure is allocated, the members of the
81 structure are initialized as follows:
82 .Bl -tag -width indent
83 .It Va "e_ident[EI_MAG0..EI_MAG3]"
84 Identification bytes at offsets
90 are set to the ELF signature.
91 .It Va "e_ident[EI_CLASS]"
92 The identification byte at offset
94 is set to the ELF class associated with the function being called
99 .It Va "e_ident[EI_DATA]"
100 The identification byte at offset
104 .It Va "e_ident[EI_VERSION]"
105 The identification byte at offset
107 is set to the ELF library's operating version set by a prior call to
116 is set to the ELF library's operating version set by a prior call to
120 Other members of the header are set to zero.
121 The application is responsible for changing these values
122 as needed before calling
125 If successful, these three functions set the
127 flag on ELF descriptor
130 These functions return a pointer to a translated header descriptor
131 if successful, or NULL on failure.
133 These functions can fail with the following errors:
134 .Bl -tag -width "[ELF_E_RESOURCE]"
135 .It Bq Er ELF_E_ARGUMENT
139 .It Bq Er ELF_E_ARGUMENT
142 was not a descriptor for an ELF object.
143 .It Bq Er ELF_E_ARGUMENT
146 had an unsupported value.
147 .It Bq Er ELF_E_ARGUMENT
148 The class of the ELF descriptor
150 did not match that of the requested operation.
151 .It Bq Er ELF_E_ARGUMENT
154 the class of argument
158 and did not match the argument
160 .It Bq Er ELF_E_CLASS
161 The ELF class of descriptor
163 did not match that of the API function being called.
164 .It Bq Er ELF_E_HEADER
165 A malformed ELF header was detected.
166 .It Bq Er ELF_E_RESOURCE
167 An out of memory condition was detected during execution.
168 .It Bq Er ELF_E_SECTION
169 The ELF descriptor in argument
171 did not adhere to the conventions used for extended numbering.
172 .It Bq Er ELF_E_VERSION
175 had an unsupported ELF version number.
179 .Xr elf32_getehdr 3 ,
180 .Xr elf64_getehdr 3 ,