]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - lib/libelf/gelf_getphdr.3
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / lib / libelf / gelf_getphdr.3
1 .\" Copyright (c) 2006 Joseph Koshy.  All rights reserved.
2 .\"
3 .\" Redistribution and use in source and binary forms, with or without
4 .\" modification, are permitted provided that the following conditions
5 .\" are met:
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.
11 .\"
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
22 .\" such damage.
23 .\"
24 .\" $FreeBSD$
25 .\"
26 .Dd December 16, 2006
27 .Os
28 .Dt GELF_GETPHDR 3
29 .Sh NAME
30 .Nm elf32_getphdr ,
31 .Nm elf64_getphdr ,
32 .Nm gelf_getphdr
33 .Nd retrieve an ELF program header table
34 .Sh LIBRARY
35 .Lb libelf
36 .Sh SYNOPSIS
37 .In libelf.h
38 .Ft "Elf32_Phdr *"
39 .Fn elf32_getphdr "Elf *elf"
40 .Ft "Elf64_Phdr *"
41 .Fn elf64_getphdr "Elf *elf"
42 .In gelf.h
43 .Ft "GElf_Phdr *"
44 .Fn gelf_getphdr "Elf *elf" "int index" "GElf_Phdr *dst"
45 .Sh DESCRIPTION
46 These functions retrieve and translate ELF program header information
47 from an ELF descriptor, if this information exists.
48 .Pp
49 Functions
50 .Fn elf32_getphdr
51 and
52 .Fn elf64_getphdr
53 return a pointer to an array of translated
54 .Vt Elf32_Phdr
55 and
56 .Vt Elf64_Phdr
57 descriptors respectively.
58 These descriptors are described in
59 .Xr elf 5 .
60 The number of entries in this array is specified by the
61 .Va e_phnum
62 field of the executable header for ELF descriptor
63 .Ar elf .
64 .Pp
65 Function
66 .Fn gelf_getphdr
67 will retrieve the program header table entry at index
68 .Ar index
69 from ELF descriptor
70 .Ar elf.
71 The translated program header table entry will be written to the
72 address pointed to be argument
73 .Ar dst .
74 .Pp
75 Applications may inform the library of modifications to a program header table entry
76 by using the
77 .Xr elf_flagphdr 3
78 API.
79 Applications using the
80 .Xr gelf 3
81 interface need to use the
82 .Xr gelf_update_phdr 3
83 API to copy modifications to a program header entry back to the underlying
84 ELF descriptor.
85 .Sh RETURN VALUES
86 The functions a valid pointer if successful, or NULL in case an error
87 was encountered.
88 .Sh ERRORS
89 These functions may fail with the following errors:
90 .Bl -tag -width "[ELF_E_RESOURCE]"
91 .It Bq Er ELF_E_ARGUMENT
92 Argument
93 .Ar elf
94 was NULL.
95 .It Bq Er ELF_E_ARGUMENT
96 Argument
97 .Ar elf
98 was not a descriptor for an ELF object.
99 .It Bq Er ELF_E_ARGUMENT
100 Argument
101 .Ar dst
102 was NULL.
103 .It Bq Er ELF_E_ARGUMENT
104 Index
105 .Ar index
106 was out of range.
107 .It Bq Er ELF_E_CLASS
108 The class of ELF descriptor
109 .Ar elf
110 did not match the expected class of the function being called.
111 .It Bq Er ELF_E_HEADER
112 ELF descriptor
113 .Ar elf
114 did not possess an executable header.
115 .It Bq Er ELF_E_HEADER
116 ELF descriptor
117 .Ar elf
118 had a corrupt executable header.
119 .It Bq Er ELF_E_RESOURCE
120 An out of memory condition was detected.
121 .It Bq Er ELF_E_SECTION
122 The ELF descriptor in argument
123 .Ar elf
124 did not adhere to the conventions used for extended numbering.
125 .It Bq Er ELF_VERSION
126 ELF descriptor
127 .Ar elf
128 was of an unsupported version.
129 .El
130 .Sh SEE ALSO
131 .Xr elf 3 ,
132 .Xr elf32_getehdr 3 ,
133 .Xr elf32_newphdr 3 ,
134 .Xr elf64_getehdr 3 ,
135 .Xr elf64_newphdr 3 ,
136 .Xr elf_flagphdr 3 ,
137 .Xr gelf 3 ,
138 .Xr gelf_getehdr 3 ,
139 .Xr gelf_newphdr 3 ,
140 .Xr gelf_update_phdr 3 ,
141 .Xr elf 5