12de3b87aSKai Wang.\" Copyright (c) 2012 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_open.3 3743 2019-06-12 19:36:30Z jkoshy $ 252de3b87aSKai Wang.\" 26*d003e0d7SEd Maste.Dd June 12, 2019 272de3b87aSKai Wang.Dt ELF_OPEN 3 28ae500c1fSEd Maste.Os 292de3b87aSKai Wang.Sh NAME 302de3b87aSKai Wang.Nm elf_open 312de3b87aSKai Wang.Nd open ELF objects and ar(1) archives 322de3b87aSKai Wang.Sh LIBRARY 332de3b87aSKai Wang.Lb libelf 342de3b87aSKai Wang.Sh SYNOPSIS 352de3b87aSKai Wang.In libelf.h 362de3b87aSKai Wang.Ft "Elf *" 372de3b87aSKai Wang.Fn elf_open "int fd" 382de3b87aSKai Wang.Ft "Elf *" 392de3b87aSKai Wang.Fn elf_openmemory "char *image" "size_t sz" 402de3b87aSKai Wang.Sh DESCRIPTION 412de3b87aSKai Wang.Em Important : 422de3b87aSKai WangThe functions 432de3b87aSKai Wang.Fn elf_open 442de3b87aSKai Wangand 452de3b87aSKai Wang.Fn elf_openmemory 46*d003e0d7SEd Masteare extensions to the 47*d003e0d7SEd Maste.Xr elf 3 48*d003e0d7SEd MasteAPI, for the internal use of the 492de3b87aSKai WangElftoolchain project. 502de3b87aSKai WangPortable applications should not use these functions. 512de3b87aSKai Wang.Pp 522de3b87aSKai WangThe function 532de3b87aSKai Wang.Fn elf_open 542de3b87aSKai Wangreturns an Elf descriptor opened with mode 552de3b87aSKai Wang.Dv ELF_C_READ 562de3b87aSKai Wangfor the ELF object or 572de3b87aSKai Wang.Xr ar 1 582de3b87aSKai Wangarchive referenced by the file descriptor in argument 592de3b87aSKai Wang.Ar fd . 602de3b87aSKai Wang.Pp 612de3b87aSKai WangThe function 622de3b87aSKai Wang.Fn elf_openmemory 632de3b87aSKai Wangreturns an ELF descriptor opened with mode 642de3b87aSKai Wang.Dv ELF_C_READ 652de3b87aSKai Wangfor the ELF object or 662de3b87aSKai Wang.Xr ar 1 672de3b87aSKai Wangarchive contained in the memory area pointed to by the argument 682de3b87aSKai Wang.Ar image . 692de3b87aSKai WangThe argument 702de3b87aSKai Wang.Ar sz 712de3b87aSKai Wangspecifies the size of the memory area in bytes. 72ae500c1fSEd Maste.Sh RETURN VALUES 73ae500c1fSEd MasteThe function returns a pointer to a ELF descriptor if successful, or 74ae500c1fSEd MasteNULL if an error occurred. 752de3b87aSKai Wang.Sh COMPATIBILITY 76*d003e0d7SEd MasteThese functions are non-standard extensions to the 77*d003e0d7SEd Maste.Xr elf 3 78*d003e0d7SEd MasteAPI set. 792de3b87aSKai Wang.Pp 802de3b87aSKai WangThe behavior of these functions differs from their counterparts 812de3b87aSKai Wang.Xr elf_begin 3 822de3b87aSKai Wangand 832de3b87aSKai Wang.Xr elf_memory 3 842de3b87aSKai Wangin that these functions will successfully open malformed ELF objects 852de3b87aSKai Wangand 862de3b87aSKai Wang.Xr ar 1 872de3b87aSKai Wangarchives, returning an Elf descriptor of type 882de3b87aSKai Wang.Dv ELF_K_NONE . 892de3b87aSKai Wang.Sh ERRORS 902de3b87aSKai WangThese functions can fail with the following errors: 912de3b87aSKai Wang.Bl -tag -width "[ELF_E_RESOURCE]" 922de3b87aSKai Wang.It Bq Er ELF_E_ARGUMENT 932de3b87aSKai WangThe argument 942de3b87aSKai Wang.Ar fd 952de3b87aSKai Wangwas of an unsupported file type. 962de3b87aSKai Wang.It Bq Er ELF_E_ARGUMENT 972de3b87aSKai WangThe argument 982de3b87aSKai Wang.Ar sz 992de3b87aSKai Wangwas zero, or the argument 1002de3b87aSKai Wang.Ar image 1012de3b87aSKai Wangwas NULL. 1022de3b87aSKai Wang.It Bq Er ELF_E_IO 1032de3b87aSKai WangThe file descriptor in argument 1042de3b87aSKai Wang.Ar fd 1052de3b87aSKai Wangwas invalid. 1062de3b87aSKai Wang.It Bq Er ELF_E_IO 1072de3b87aSKai WangThe file descriptor in argument 1082de3b87aSKai Wang.Ar fd 1092de3b87aSKai Wangcould not be read. 1102de3b87aSKai Wang.It Bq Er ELF_E_RESOURCE 1112de3b87aSKai WangAn out of memory condition was encountered. 1122de3b87aSKai Wang.It Bq Er ELF_E_SEQUENCE 1132de3b87aSKai WangFunctions 1142de3b87aSKai Wang.Fn elf_open 1152de3b87aSKai Wangor 1162de3b87aSKai Wang.Fn elf_openmemory 1172de3b87aSKai Wangwas called before a working version was established with 1182de3b87aSKai Wang.Xr elf_version 3 . 1192de3b87aSKai Wang.El 1202de3b87aSKai Wang.Sh SEE ALSO 1212de3b87aSKai Wang.Xr elf 3 , 1222de3b87aSKai Wang.Xr elf_begin 3 , 1232de3b87aSKai Wang.Xr elf_errno 3 , 1242de3b87aSKai Wang.Xr elf_memory 3 , 1252de3b87aSKai Wang.Xr gelf 3 126