summaryrefslogtreecommitdiff
path: root/lib/libelf/elf_flagdata.3
blob: f4ab6ed1fafd1cf4325bc9a00012cca3f9d747be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
.\" Copyright (c) 2006-2008,2011 Joseph Koshy.  All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" This software is provided by Joseph Koshy ``as is'' and
.\" any express or implied warranties, including, but not limited to, the
.\" implied warranties of merchantability and fitness for a particular purpose
.\" are disclaimed.  in no event shall Joseph Koshy be liable
.\" for any direct, indirect, incidental, special, exemplary, or consequential
.\" damages (including, but not limited to, procurement of substitute goods
.\" or services; loss of use, data, or profits; or business interruption)
.\" however caused and on any theory of liability, whether in contract, strict
.\" liability, or tort (including negligence or otherwise) arising in any way
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
.\" $Id: elf_flagdata.3,v 1.3 2020/05/18 06:46:23 jsg Exp $
.\"
.Dd June 12, 2019
.Dt ELF_FLAGDATA 3
.Os
.Sh NAME
.Nm elf_flagarhdr ,
.Nm elf_flagdata ,
.Nm elf_flagehdr ,
.Nm elf_flagelf ,
.Nm elf_flagphdr ,
.Nm elf_flagscn ,
.Nm elf_flagshdr
.Nd manipulate flags associated with ELF data structures
.Sh LIBRARY
.Lb libelf
.Sh SYNOPSIS
.In libelf.h
.Ft "unsigned int"
.Fn elf_flagarhdr "Elf_Arhdr *arhdr" "Elf_Cmd cmd" "unsigned int flags"
.Ft "unsigned int"
.Fn elf_flagdata "Elf_Data *data" "Elf_Cmd cmd" "unsigned int flags"
.Ft "unsigned int"
.Fn elf_flagehdr "Elf *elf" "Elf_Cmd cmd" "unsigned int flags"
.Ft "unsigned int"
.Fn elf_flagelf "Elf *elf" "Elf_Cmd cmd" "unsigned int flags"
.Ft "unsigned int"
.Fn elf_flagphdr "Elf *elf" "Elf_Cmd cmd" "unsigned int flags"
.Ft "unsigned int"
.Fn elf_flagscn "Elf_Scn *scn" "Elf_Cmd cmd" "unsigned int flags"
.Ft "unsigned int"
.Fn elf_flagshdr "Elf_Scn *scn" "Elf_Cmd cmd" "unsigned int flags"
.Sh DESCRIPTION
These functions are used to query, set or reset flags on data
structures associated with an ELF file.
.Pp
Arguments
.Ar arhdr ,
.Ar data ,
.Ar elf
and
.Ar scn
denote the data structures whose flags need to be changed.
These values should have been returned by prior calls to
functions in the
.Xr elf 3
API set:
.Bl -bullet -compact
.It
Argument
.Ar arhdr
should have been returned by a prior call to
.Xr elf_getarhdr 3 .
.It
Argument
.Ar data
should have been returned by a prior call to one of
.Xr elf_newdata 3 ,
.Xr elf_getdata 3
or
.Xr elf_rawdata 3 .
.It
Argument
.Ar elf
should have been allocated by a prior call to one of
.Xr elf_begin 3
or
.Xr elf_memory 3 .
.It
Argument
.Ar scn
should have been returned by a prior call to one of
.Xr elf_getscn 3 ,
.Xr elf_newscn 3
or
.Xr elf_nextscn 3 .
.El
These values are allowed to be NULL to simplify error handling in
application code.
.Pp
Argument
.Ar cmd
may have the following values:
.Bl -tag -width ELF_C_SET
.It Dv ELF_C_CLR
The argument
.Ar flags
specifies the flags to be cleared.
.It Dv ELF_C_SET
The argument
.Ar flags
specifies the flags to be set.
.El
.Pp
The argument
.Ar flags
is allowed to have the following flags set:
.Bl -tag -width ELF_F_ARCHIVE_SYSV
.It Dv ELF_F_ARCHIVE
This flag is only valid with the
.Fn elf_flagelf
API.
It informs the library that the application desires to create an
.Xr ar 1
archive.
Argument
.Ar elf
should have been opened for writing using the
.Dv ELF_C_WRITE
command to function
.Fn elf_begin .
.It Dv ELF_F_ARCHIVE_SYSV
This flag is used in conjunction with the
.Dv ELF_F_ARCHIVE
flag to indicate that library should create archives that conform
to System V layout rules.
The default is to create BSD style archives.
.It Dv ELF_F_DIRTY
Mark the associated data structure as needing to be written back
to the underlying file.
A subsequent call to
.Xr elf_update 3
will resynchronize the library's internal data structures.
.It Dv ELF_F_LAYOUT
This flag is only valid with the
.Fn elf_flagelf
API.
It informs the library that the application will take
responsibility for the layout of the file and that the library is
not to insert any padding in between sections.
.El
.Pp
Marking a given data structure as
.Dq dirty
affects all of its contained elements.
Thus marking an ELF descriptor
.Ar elf
with
.Fn elf_flagelf "elf" "ELF_C_SET" "ELF_F_DIRTY"
means that the entire contents of the descriptor are
.Dq dirty .
.Pp
Using a value of zero for argument
.Ar flags
will return the current set of flags for the data structure being
queried.
.Sh RETURN VALUES
These functions return the updated flags if successful, or zero if
an error is detected.
.Sh COMPATIBILITY
The
.Fn elf_flagarhdr
function and the
.Dv ELF_F_ARCHIVE
and
.Dv ELF_F_ARCHIVE_SYSV
flags are an extension to the
.Xr elf 3
API.
.Sh ERRORS
These functions may fail with the following errors:
.Bl -tag -width "[ELF_E_RESOURCE]"
.It Bq Er ELF_E_ARGUMENT
An unsupported value was used for the
.Ar cmd
argument.
.It Bq Er ELF_E_ARGUMENT
Argument
.Ar flags
had unsupported flags set.
.It Bq Er ELF_E_ARGUMENT
The argument
.Ar elf
was not a descriptor for an ELF object.
.It Bq Er ELF_E_MODE
The
.Dv ELF_F_ARCHIVE
flag was used with an ELF descriptor that had not been opened for writing.
.It Bq Er ELF_E_SEQUENCE
Function
.Fn elf_flagehdr
was called without an executable header being allocated.
.It Bq Er ELF_E_SEQUENCE
Function
.Fn elf_flagphdr
was called without a program header being allocated.
.El
.Sh SEE ALSO
.Xr elf 3 ,
.Xr elf32_newehdr 3 ,
.Xr elf32_newphdr 3 ,
.Xr elf64_newehdr 3 ,
.Xr elf64_newphdr 3 ,
.Xr elf_newdata 3 ,
.Xr elf_update 3 ,
.Xr gelf 3 ,
.Xr gelf_newehdr 3 ,
.Xr gelf_newphdr 3 ,
.Xr gelf_update_dyn 3 ,
.Xr gelf_update_move 3 ,
.Xr gelf_update_rel 3 ,
.Xr gelf_update_rela 3 ,
.Xr gelf_update_sym 3 ,
.Xr gelf_update_syminfo 3