summaryrefslogtreecommitdiffstats
path: root/lib/libelf/elf_flagdata.3
blob: b07e5242681f969d698164c0df6832a36223ad7a (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
.\" Copyright (c) 2006,2007 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.
.\"
.\" $FreeBSD$
.\"
.Dd October 22, 2007
.Dt ELF_FLAGDATA 3
.Os
.Sh NAME
.Nm elf_flagdata ,
.Nm elf_flagehdr ,
.Nm elf_flagelf ,
.Nm elf_flagphdr ,
.Nm elf_flagscn ,
.Nm elf_flagshdr
.Nd manipulate flags associated with ELF(3) data structures
.Sh LIBRARY
.Lb libelf
.Sh SYNOPSIS
.In libelf.h
.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 data ,
.Ar elf
and
.Ar scn
denote the data structures whose flags need to be changed.
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_LAYOUT
.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 is successful, and zero if
an error is detected.
.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_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 elf32_newshdr 3 ,
.Xr elf64_newehdr 3 ,
.Xr elf64_newphdr 3 ,
.Xr elf64_newshdr 3 ,
.Xr elf_newdata 3 ,
.Xr elf_update 3 ,
.Xr gelf 3 ,
.Xr gelf_newehdr 3 ,
.Xr gelf_newphdr 3 ,
.Xr gelf_newshdr 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
OpenPOWER on IntegriCloud