]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/elftoolchain/libelf/elf_flagdata.3
Merge compiler-rt trunk r351319, and resolve conflicts.
[FreeBSD/FreeBSD.git] / contrib / elftoolchain / libelf / elf_flagdata.3
1 .\" Copyright (c) 2006-2008,2011 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 .\" $Id: elf_flagdata.3 3639 2018-10-14 14:07:02Z jkoshy $
25 .\"
26 .Dd December 3, 2011
27 .Dt ELF_FLAGDATA 3
28 .Os
29 .Sh NAME
30 .Nm elf_flagarhdr ,
31 .Nm elf_flagdata ,
32 .Nm elf_flagehdr ,
33 .Nm elf_flagelf ,
34 .Nm elf_flagphdr ,
35 .Nm elf_flagscn ,
36 .Nm elf_flagshdr
37 .Nd manipulate flags associated with ELF(3) data structures
38 .Sh LIBRARY
39 .Lb libelf
40 .Sh SYNOPSIS
41 .In libelf.h
42 .Ft "unsigned int"
43 .Fn elf_flagarhdr "Elf_Arhdr *arhdr" "Elf_Cmd cmd" "unsigned int flags"
44 .Ft "unsigned int"
45 .Fn elf_flagdata "Elf_Data *data" "Elf_Cmd cmd" "unsigned int flags"
46 .Ft "unsigned int"
47 .Fn elf_flagehdr "Elf *elf" "Elf_Cmd cmd" "unsigned int flags"
48 .Ft "unsigned int"
49 .Fn elf_flagelf "Elf *elf" "Elf_Cmd cmd" "unsigned int flags"
50 .Ft "unsigned int"
51 .Fn elf_flagphdr "Elf *elf" "Elf_Cmd cmd" "unsigned int flags"
52 .Ft "unsigned int"
53 .Fn elf_flagscn "Elf_Scn *scn" "Elf_Cmd cmd" "unsigned int flags"
54 .Ft "unsigned int"
55 .Fn elf_flagshdr "Elf_Scn *scn" "Elf_Cmd cmd" "unsigned int flags"
56 .Sh DESCRIPTION
57 These functions are used to query, set or reset flags on data
58 structures associated with an ELF file.
59 .Pp
60 Arguments
61 .Ar arhdr ,
62 .Ar data ,
63 .Ar elf
64 and
65 .Ar scn
66 denote the data structures whose flags need to be changed.
67 These values should have been returned by prior calls to
68 functions in the ELF(3) API set:
69 .Bl -bullet -compact
70 .It
71 Argument
72 .Ar arhdr
73 should have been returned by a prior call to
74 .Xr elf_getarhdr 3 .
75 .It
76 Argument
77 .Ar data
78 should have been returned by a prior call to one of
79 .Xr elf_newdata 3 ,
80 .Xr elf_getdata 3
81 or
82 .Xr elf_rawdata 3 .
83 .It
84 Argument
85 .Ar elf
86 should have been allocated by a prior call to one of
87 .Xr elf_begin 3
88 or
89 .Xr elf_memory 3 .
90 .It
91 Argument
92 .Ar scn
93 should have been returned by a prior call to one of
94 .Xr elf_getscn 3 ,
95 .Xr elf_newscn 3
96 or
97 .Xr elf_nextscn 3 .
98 .El
99 These values are allowed to be NULL to simplify error handling in
100 application code.
101 .Pp
102 Argument
103 .Ar cmd
104 may have the following values:
105 .Bl -tag -width ELF_C_SET
106 .It Dv ELF_C_CLR
107 The argument
108 .Ar flags
109 specifies the flags to be cleared.
110 .It Dv ELF_C_SET
111 The argument
112 .Ar flags
113 specifies the flags to be set.
114 .El
115 .Pp
116 The argument
117 .Ar flags
118 is allowed to have the following flags set:
119 .Bl -tag -width ELF_F_ARCHIVE_SYSV
120 .It Dv ELF_F_ARCHIVE
121 This flag is only valid with the
122 .Fn elf_flagelf
123 API.
124 It informs the library that the application desires to create an
125 .Xr ar 1
126 archive.
127 Argument
128 .Ar elf
129 should have been opened for writing using the
130 .Dv ELF_C_WRITE
131 command to function
132 .Fn elf_begin .
133 .It Dv ELF_F_ARCHIVE_SYSV
134 This flag is used in conjunction with the
135 .Dv ELF_F_ARCHIVE
136 flag to indicate that library should create archives that conform
137 to System V layout rules.
138 The default is to create BSD style archives.
139 .It Dv ELF_F_DIRTY
140 Mark the associated data structure as needing to be written back
141 to the underlying file.
142 A subsequent call to
143 .Xr elf_update 3
144 will resynchronize the library's internal data structures.
145 .It Dv ELF_F_LAYOUT
146 This flag is only valid with the
147 .Fn elf_flagelf
148 API.
149 It informs the library that the application will take
150 responsibility for the layout of the file and that the library is
151 not to insert any padding in between sections.
152 .El
153 .Pp
154 Marking a given data structure as
155 .Dq dirty
156 affects all of its contained elements.
157 Thus marking an ELF descriptor
158 .Ar elf
159 with
160 .Fn elf_flagelf "elf" "ELF_C_SET" "ELF_F_DIRTY"
161 means that the entire contents of the descriptor are
162 .Dq dirty .
163 .Pp
164 Using a value of zero for argument
165 .Ar flags
166 will return the current set of flags for the data structure being
167 queried.
168 .Sh RETURN VALUES
169 These functions return the updated flags if successful, or zero if
170 an error is detected.
171 .Sh COMPATIBILITY
172 The
173 .Fn elf_flagarhdr
174 function and the
175 .Dv ELF_F_ARCHIVE
176 and
177 .Dv ELF_F_ARCHIVE_SYSV
178 flags are an extension to the ELF(3) API.
179 .Sh ERRORS
180 These functions may fail with the following errors:
181 .Bl -tag -width "[ELF_E_RESOURCE]"
182 .It Bq Er ELF_E_ARGUMENT
183 An unsupported value was used for the
184 .Ar cmd
185 argument.
186 .It Bq Er ELF_E_ARGUMENT
187 Argument
188 .Ar flags
189 had unsupported flags set.
190 .It Bq Er ELF_E_ARGUMENT
191 The argument
192 .Ar elf
193 was not a descriptor for an ELF object.
194 .It Bq Er ELF_E_MODE
195 The
196 .Dv ELF_F_ARCHIVE
197 flag was used with an ELF descriptor that had not been opened for writing.
198 .It Bq Er ELF_E_SEQUENCE
199 Function
200 .Fn elf_flagehdr
201 was called without an executable header being allocated.
202 .It Bq Er ELF_E_SEQUENCE
203 Function
204 .Fn elf_flagphdr
205 was called without a program header being allocated.
206 .El
207 .Sh SEE ALSO
208 .Xr elf 3 ,
209 .Xr elf32_newehdr 3 ,
210 .Xr elf32_newphdr 3 ,
211 .Xr elf64_newehdr 3 ,
212 .Xr elf64_newphdr 3 ,
213 .Xr elf_newdata 3 ,
214 .Xr elf_update 3 ,
215 .Xr gelf 3 ,
216 .Xr gelf_newehdr 3 ,
217 .Xr gelf_newphdr 3 ,
218 .Xr gelf_update_dyn 3 ,
219 .Xr gelf_update_move 3 ,
220 .Xr gelf_update_rel 3 ,
221 .Xr gelf_update_rela 3 ,
222 .Xr gelf_update_sym 3 ,
223 .Xr gelf_update_syminfo 3