12de3b87aSKai Wang.\" Copyright (c) 2006-2008,2011 Joseph Koshy.  All rights reserved.
22de3b87aSKai Wang.\"
32de3b87aSKai Wang.\" Redistribution and use in source and binary forms, with or without
42de3b87aSKai Wang.\" modification, are permitted provided that the following conditions
52de3b87aSKai Wang.\" are met:
62de3b87aSKai Wang.\" 1. Redistributions of source code must retain the above copyright
72de3b87aSKai Wang.\"    notice, this list of conditions and the following disclaimer.
82de3b87aSKai Wang.\" 2. Redistributions in binary form must reproduce the above copyright
92de3b87aSKai Wang.\"    notice, this list of conditions and the following disclaimer in the
102de3b87aSKai Wang.\"    documentation and/or other materials provided with the distribution.
112de3b87aSKai Wang.\"
122de3b87aSKai Wang.\" This software is provided by Joseph Koshy ``as is'' and
132de3b87aSKai Wang.\" any express or implied warranties, including, but not limited to, the
142de3b87aSKai Wang.\" implied warranties of merchantability and fitness for a particular purpose
152de3b87aSKai Wang.\" are disclaimed.  in no event shall Joseph Koshy be liable
162de3b87aSKai Wang.\" for any direct, indirect, incidental, special, exemplary, or consequential
172de3b87aSKai Wang.\" damages (including, but not limited to, procurement of substitute goods
182de3b87aSKai Wang.\" or services; loss of use, data, or profits; or business interruption)
192de3b87aSKai Wang.\" however caused and on any theory of liability, whether in contract, strict
202de3b87aSKai Wang.\" liability, or tort (including negligence or otherwise) arising in any way
212de3b87aSKai Wang.\" out of the use of this software, even if advised of the possibility of
222de3b87aSKai Wang.\" such damage.
232de3b87aSKai Wang.\"
24*d003e0d7SEd Maste.\" $Id: elf_flagdata.3 3743 2019-06-12 19:36:30Z jkoshy $
252de3b87aSKai Wang.\"
26*d003e0d7SEd Maste.Dd June 12, 2019
272de3b87aSKai Wang.Dt ELF_FLAGDATA 3
28ae500c1fSEd Maste.Os
292de3b87aSKai Wang.Sh NAME
302de3b87aSKai Wang.Nm elf_flagarhdr ,
312de3b87aSKai Wang.Nm elf_flagdata ,
322de3b87aSKai Wang.Nm elf_flagehdr ,
332de3b87aSKai Wang.Nm elf_flagelf ,
342de3b87aSKai Wang.Nm elf_flagphdr ,
352de3b87aSKai Wang.Nm elf_flagscn ,
362de3b87aSKai Wang.Nm elf_flagshdr
37*d003e0d7SEd Maste.Nd manipulate flags associated with ELF data structures
382de3b87aSKai Wang.Sh LIBRARY
392de3b87aSKai Wang.Lb libelf
402de3b87aSKai Wang.Sh SYNOPSIS
412de3b87aSKai Wang.In libelf.h
422de3b87aSKai Wang.Ft "unsigned int"
432de3b87aSKai Wang.Fn elf_flagarhdr "Elf_Arhdr *arhdr" "Elf_Cmd cmd" "unsigned int flags"
442de3b87aSKai Wang.Ft "unsigned int"
452de3b87aSKai Wang.Fn elf_flagdata "Elf_Data *data" "Elf_Cmd cmd" "unsigned int flags"
462de3b87aSKai Wang.Ft "unsigned int"
472de3b87aSKai Wang.Fn elf_flagehdr "Elf *elf" "Elf_Cmd cmd" "unsigned int flags"
482de3b87aSKai Wang.Ft "unsigned int"
492de3b87aSKai Wang.Fn elf_flagelf "Elf *elf" "Elf_Cmd cmd" "unsigned int flags"
502de3b87aSKai Wang.Ft "unsigned int"
512de3b87aSKai Wang.Fn elf_flagphdr "Elf *elf" "Elf_Cmd cmd" "unsigned int flags"
522de3b87aSKai Wang.Ft "unsigned int"
532de3b87aSKai Wang.Fn elf_flagscn "Elf_Scn *scn" "Elf_Cmd cmd" "unsigned int flags"
542de3b87aSKai Wang.Ft "unsigned int"
552de3b87aSKai Wang.Fn elf_flagshdr "Elf_Scn *scn" "Elf_Cmd cmd" "unsigned int flags"
562de3b87aSKai Wang.Sh DESCRIPTION
572de3b87aSKai WangThese functions are used to query, set or reset flags on data
582de3b87aSKai Wangstructures associated with an ELF file.
592de3b87aSKai Wang.Pp
602de3b87aSKai WangArguments
612de3b87aSKai Wang.Ar arhdr ,
622de3b87aSKai Wang.Ar data ,
632de3b87aSKai Wang.Ar elf
642de3b87aSKai Wangand
652de3b87aSKai Wang.Ar scn
662de3b87aSKai Wangdenote the data structures whose flags need to be changed.
672de3b87aSKai WangThese values should have been returned by prior calls to
68*d003e0d7SEd Mastefunctions in the
69*d003e0d7SEd Maste.Xr elf 3
70*d003e0d7SEd MasteAPI set:
712de3b87aSKai Wang.Bl -bullet -compact
722de3b87aSKai Wang.It
732de3b87aSKai WangArgument
742de3b87aSKai Wang.Ar arhdr
752de3b87aSKai Wangshould have been returned by a prior call to
762de3b87aSKai Wang.Xr elf_getarhdr 3 .
772de3b87aSKai Wang.It
782de3b87aSKai WangArgument
792de3b87aSKai Wang.Ar data
802de3b87aSKai Wangshould have been returned by a prior call to one of
812de3b87aSKai Wang.Xr elf_newdata 3 ,
822de3b87aSKai Wang.Xr elf_getdata 3
832de3b87aSKai Wangor
842de3b87aSKai Wang.Xr elf_rawdata 3 .
852de3b87aSKai Wang.It
862de3b87aSKai WangArgument
872de3b87aSKai Wang.Ar elf
882de3b87aSKai Wangshould have been allocated by a prior call to one of
892de3b87aSKai Wang.Xr elf_begin 3
902de3b87aSKai Wangor
912de3b87aSKai Wang.Xr elf_memory 3 .
922de3b87aSKai Wang.It
932de3b87aSKai WangArgument
942de3b87aSKai Wang.Ar scn
952de3b87aSKai Wangshould have been returned by a prior call to one of
962de3b87aSKai Wang.Xr elf_getscn 3 ,
972de3b87aSKai Wang.Xr elf_newscn 3
982de3b87aSKai Wangor
992de3b87aSKai Wang.Xr elf_nextscn 3 .
1002de3b87aSKai Wang.El
1012de3b87aSKai WangThese values are allowed to be NULL to simplify error handling in
1022de3b87aSKai Wangapplication code.
1032de3b87aSKai Wang.Pp
1042de3b87aSKai WangArgument
1052de3b87aSKai Wang.Ar cmd
1062de3b87aSKai Wangmay have the following values:
1072de3b87aSKai Wang.Bl -tag -width ELF_C_SET
1082de3b87aSKai Wang.It Dv ELF_C_CLR
1092de3b87aSKai WangThe argument
1102de3b87aSKai Wang.Ar flags
1112de3b87aSKai Wangspecifies the flags to be cleared.
1122de3b87aSKai Wang.It Dv ELF_C_SET
1132de3b87aSKai WangThe argument
1142de3b87aSKai Wang.Ar flags
1152de3b87aSKai Wangspecifies the flags to be set.
1162de3b87aSKai Wang.El
1172de3b87aSKai Wang.Pp
1182de3b87aSKai WangThe argument
1192de3b87aSKai Wang.Ar flags
1202de3b87aSKai Wangis allowed to have the following flags set:
1212de3b87aSKai Wang.Bl -tag -width ELF_F_ARCHIVE_SYSV
1222de3b87aSKai Wang.It Dv ELF_F_ARCHIVE
1232de3b87aSKai WangThis flag is only valid with the
1242de3b87aSKai Wang.Fn elf_flagelf
1252de3b87aSKai WangAPI.
1262de3b87aSKai WangIt informs the library that the application desires to create an
1272de3b87aSKai Wang.Xr ar 1
1282de3b87aSKai Wangarchive.
1292de3b87aSKai WangArgument
1302de3b87aSKai Wang.Ar elf
1312de3b87aSKai Wangshould have been opened for writing using the
1322de3b87aSKai Wang.Dv ELF_C_WRITE
1332de3b87aSKai Wangcommand to function
1342de3b87aSKai Wang.Fn elf_begin .
1352de3b87aSKai Wang.It Dv ELF_F_ARCHIVE_SYSV
1362de3b87aSKai WangThis flag is used in conjunction with the
1372de3b87aSKai Wang.Dv ELF_F_ARCHIVE
1382de3b87aSKai Wangflag to indicate that library should create archives that conform
1392de3b87aSKai Wangto System V layout rules.
1402de3b87aSKai WangThe default is to create BSD style archives.
1412de3b87aSKai Wang.It Dv ELF_F_DIRTY
1422de3b87aSKai WangMark the associated data structure as needing to be written back
1432de3b87aSKai Wangto the underlying file.
1442de3b87aSKai WangA subsequent call to
1452de3b87aSKai Wang.Xr elf_update 3
1462de3b87aSKai Wangwill resynchronize the library's internal data structures.
1472de3b87aSKai Wang.It Dv ELF_F_LAYOUT
1482de3b87aSKai WangThis flag is only valid with the
1492de3b87aSKai Wang.Fn elf_flagelf
1502de3b87aSKai WangAPI.
1512de3b87aSKai WangIt informs the library that the application will take
1522de3b87aSKai Wangresponsibility for the layout of the file and that the library is
1532de3b87aSKai Wangnot to insert any padding in between sections.
1542de3b87aSKai Wang.El
1552de3b87aSKai Wang.Pp
1562de3b87aSKai WangMarking a given data structure as
1572de3b87aSKai Wang.Dq dirty
1582de3b87aSKai Wangaffects all of its contained elements.
1592de3b87aSKai WangThus marking an ELF descriptor
1602de3b87aSKai Wang.Ar elf
1612de3b87aSKai Wangwith
1622de3b87aSKai Wang.Fn elf_flagelf "elf" "ELF_C_SET" "ELF_F_DIRTY"
1632de3b87aSKai Wangmeans that the entire contents of the descriptor are
1642de3b87aSKai Wang.Dq dirty .
1652de3b87aSKai Wang.Pp
1662de3b87aSKai WangUsing a value of zero for argument
1672de3b87aSKai Wang.Ar flags
1682de3b87aSKai Wangwill return the current set of flags for the data structure being
1692de3b87aSKai Wangqueried.
1702de3b87aSKai Wang.Sh RETURN VALUES
1712de3b87aSKai WangThese functions return the updated flags if successful, or zero if
1722de3b87aSKai Wangan error is detected.
1732de3b87aSKai Wang.Sh COMPATIBILITY
1742de3b87aSKai WangThe
1752de3b87aSKai Wang.Fn elf_flagarhdr
1762de3b87aSKai Wangfunction and the
1772de3b87aSKai Wang.Dv ELF_F_ARCHIVE
1782de3b87aSKai Wangand
1792de3b87aSKai Wang.Dv ELF_F_ARCHIVE_SYSV
180*d003e0d7SEd Masteflags are an extension to the
181*d003e0d7SEd Maste.Xr elf 3
182*d003e0d7SEd MasteAPI.
1832de3b87aSKai Wang.Sh ERRORS
1842de3b87aSKai WangThese functions may fail with the following errors:
1852de3b87aSKai Wang.Bl -tag -width "[ELF_E_RESOURCE]"
1862de3b87aSKai Wang.It Bq Er ELF_E_ARGUMENT
1872de3b87aSKai WangAn unsupported value was used for the
1882de3b87aSKai Wang.Ar cmd
1892de3b87aSKai Wangargument.
1902de3b87aSKai Wang.It Bq Er ELF_E_ARGUMENT
1912de3b87aSKai WangArgument
1922de3b87aSKai Wang.Ar flags
1932de3b87aSKai Wanghad unsupported flags set.
1942de3b87aSKai Wang.It Bq Er ELF_E_ARGUMENT
1952de3b87aSKai WangThe argument
1962de3b87aSKai Wang.Ar elf
1972de3b87aSKai Wangwas not a descriptor for an ELF object.
1982de3b87aSKai Wang.It Bq Er ELF_E_MODE
1992de3b87aSKai WangThe
2002de3b87aSKai Wang.Dv ELF_F_ARCHIVE
2012de3b87aSKai Wangflag was used with an ELF descriptor that had not been opened for writing.
2022de3b87aSKai Wang.It Bq Er ELF_E_SEQUENCE
2032de3b87aSKai WangFunction
2042de3b87aSKai Wang.Fn elf_flagehdr
2052de3b87aSKai Wangwas called without an executable header being allocated.
2062de3b87aSKai Wang.It Bq Er ELF_E_SEQUENCE
2072de3b87aSKai WangFunction
2082de3b87aSKai Wang.Fn elf_flagphdr
2092de3b87aSKai Wangwas called without a program header being allocated.
2102de3b87aSKai Wang.El
2112de3b87aSKai Wang.Sh SEE ALSO
2122de3b87aSKai Wang.Xr elf 3 ,
2132de3b87aSKai Wang.Xr elf32_newehdr 3 ,
2142de3b87aSKai Wang.Xr elf32_newphdr 3 ,
2152de3b87aSKai Wang.Xr elf64_newehdr 3 ,
2162de3b87aSKai Wang.Xr elf64_newphdr 3 ,
2172de3b87aSKai Wang.Xr elf_newdata 3 ,
2182de3b87aSKai Wang.Xr elf_update 3 ,
2192de3b87aSKai Wang.Xr gelf 3 ,
2202de3b87aSKai Wang.Xr gelf_newehdr 3 ,
2212de3b87aSKai Wang.Xr gelf_newphdr 3 ,
2222de3b87aSKai Wang.Xr gelf_update_dyn 3 ,
2232de3b87aSKai Wang.Xr gelf_update_move 3 ,
2242de3b87aSKai Wang.Xr gelf_update_rel 3 ,
2252de3b87aSKai Wang.Xr gelf_update_rela 3 ,
2262de3b87aSKai Wang.Xr gelf_update_sym 3 ,
2272de3b87aSKai Wang.Xr gelf_update_syminfo 3
228