]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/elftoolchain/libelf/elf_open.3
Import PCG-C into sys/contrib
[FreeBSD/FreeBSD.git] / contrib / elftoolchain / libelf / elf_open.3
1 .\" Copyright (c) 2012 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_open.3 3743 2019-06-12 19:36:30Z jkoshy $
25 .\"
26 .Dd June 12, 2019
27 .Dt ELF_OPEN 3
28 .Os
29 .Sh NAME
30 .Nm elf_open
31 .Nd open ELF objects and ar(1) archives
32 .Sh LIBRARY
33 .Lb libelf
34 .Sh SYNOPSIS
35 .In libelf.h
36 .Ft "Elf *"
37 .Fn elf_open "int fd"
38 .Ft "Elf *"
39 .Fn elf_openmemory "char *image" "size_t sz"
40 .Sh DESCRIPTION
41 .Em Important :
42 The functions
43 .Fn elf_open
44 and
45 .Fn elf_openmemory
46 are extensions to the
47 .Xr elf 3
48 API, for the internal use of the
49 Elftoolchain project.
50 Portable applications should not use these functions.
51 .Pp
52 The function
53 .Fn elf_open
54 returns an Elf descriptor opened with mode
55 .Dv ELF_C_READ
56 for the ELF object or
57 .Xr ar 1
58 archive referenced by the file descriptor in argument
59 .Ar fd .
60 .Pp
61 The function
62 .Fn elf_openmemory
63 returns an ELF descriptor opened with mode
64 .Dv ELF_C_READ
65 for the ELF object or
66 .Xr ar 1
67 archive contained in the memory area pointed to by the argument
68 .Ar image .
69 The argument
70 .Ar sz
71 specifies the size of the memory area in bytes.
72 .Sh RETURN VALUES
73 The function returns a pointer to a ELF descriptor if successful, or
74 NULL if an error occurred.
75 .Sh COMPATIBILITY
76 These functions are non-standard extensions to the
77 .Xr elf 3
78 API set.
79 .Pp
80 The behavior of these functions differs from their counterparts
81 .Xr elf_begin 3
82 and
83 .Xr elf_memory 3
84 in that these functions will successfully open malformed ELF objects
85 and
86 .Xr ar 1
87 archives, returning an Elf descriptor of type
88 .Dv ELF_K_NONE .
89 .Sh ERRORS
90 These functions can fail with the following errors:
91 .Bl -tag -width "[ELF_E_RESOURCE]"
92 .It Bq Er ELF_E_ARGUMENT
93 The argument
94 .Ar fd
95 was of an unsupported file type.
96 .It Bq Er ELF_E_ARGUMENT
97 The argument
98 .Ar sz
99 was zero, or the argument
100 .Ar image
101 was NULL.
102 .It Bq Er ELF_E_IO
103 The file descriptor in argument
104 .Ar fd
105 was invalid.
106 .It Bq Er ELF_E_IO
107 The file descriptor in argument
108 .Ar fd
109 could not be read.
110 .It Bq Er ELF_E_RESOURCE
111 An out of memory condition was encountered.
112 .It Bq Er ELF_E_SEQUENCE
113 Functions
114 .Fn elf_open
115 or
116 .Fn elf_openmemory
117 was called before a working version was established with
118 .Xr elf_version 3 .
119 .El
120 .Sh SEE ALSO
121 .Xr elf 3 ,
122 .Xr elf_begin 3 ,
123 .Xr elf_errno 3 ,
124 .Xr elf_memory 3 ,
125 .Xr gelf 3