1*0a6a1f1dSLionel Sambuc.\" $NetBSD: elf_open.3,v 1.2 2014/03/09 16:58:04 christos Exp $ 2*0a6a1f1dSLionel Sambuc.\" 3*0a6a1f1dSLionel Sambuc.\" Copyright (c) 2012 Joseph Koshy. All rights reserved. 4*0a6a1f1dSLionel Sambuc.\" 5*0a6a1f1dSLionel Sambuc.\" Redistribution and use in source and binary forms, with or without 6*0a6a1f1dSLionel Sambuc.\" modification, are permitted provided that the following conditions 7*0a6a1f1dSLionel Sambuc.\" are met: 8*0a6a1f1dSLionel Sambuc.\" 1. Redistributions of source code must retain the above copyright 9*0a6a1f1dSLionel Sambuc.\" notice, this list of conditions and the following disclaimer. 10*0a6a1f1dSLionel Sambuc.\" 2. Redistributions in binary form must reproduce the above copyright 11*0a6a1f1dSLionel Sambuc.\" notice, this list of conditions and the following disclaimer in the 12*0a6a1f1dSLionel Sambuc.\" documentation and/or other materials provided with the distribution. 13*0a6a1f1dSLionel Sambuc.\" 14*0a6a1f1dSLionel Sambuc.\" This software is provided by Joseph Koshy ``as is'' and 15*0a6a1f1dSLionel Sambuc.\" any express or implied warranties, including, but not limited to, the 16*0a6a1f1dSLionel Sambuc.\" implied warranties of merchantability and fitness for a particular purpose 17*0a6a1f1dSLionel Sambuc.\" are disclaimed. in no event shall Joseph Koshy be liable 18*0a6a1f1dSLionel Sambuc.\" for any direct, indirect, incidental, special, exemplary, or consequential 19*0a6a1f1dSLionel Sambuc.\" damages (including, but not limited to, procurement of substitute goods 20*0a6a1f1dSLionel Sambuc.\" or services; loss of use, data, or profits; or business interruption) 21*0a6a1f1dSLionel Sambuc.\" however caused and on any theory of liability, whether in contract, strict 22*0a6a1f1dSLionel Sambuc.\" liability, or tort (including negligence or otherwise) arising in any way 23*0a6a1f1dSLionel Sambuc.\" out of the use of this software, even if advised of the possibility of 24*0a6a1f1dSLionel Sambuc.\" such damage. 25*0a6a1f1dSLionel Sambuc.\" 26*0a6a1f1dSLionel Sambuc.\" Id: elf_open.3 2512 2012-05-31 06:15:57Z jkoshy 27*0a6a1f1dSLionel Sambuc.\" 28*0a6a1f1dSLionel Sambuc.Dd May 31, 2012 29*0a6a1f1dSLionel Sambuc.Os 30*0a6a1f1dSLionel Sambuc.Dt ELF_OPEN 3 31*0a6a1f1dSLionel Sambuc.Sh NAME 32*0a6a1f1dSLionel Sambuc.Nm elf_open 33*0a6a1f1dSLionel Sambuc.Nd open ELF objects and ar(1) archives 34*0a6a1f1dSLionel Sambuc.Sh LIBRARY 35*0a6a1f1dSLionel Sambuc.Lb libelf 36*0a6a1f1dSLionel Sambuc.Sh SYNOPSIS 37*0a6a1f1dSLionel Sambuc.In libelf.h 38*0a6a1f1dSLionel Sambuc.Ft "Elf *" 39*0a6a1f1dSLionel Sambuc.Fn elf_open "int fd" 40*0a6a1f1dSLionel Sambuc.Ft "Elf *" 41*0a6a1f1dSLionel Sambuc.Fn elf_openmemory "char *image" "size_t sz" 42*0a6a1f1dSLionel Sambuc.Sh DESCRIPTION 43*0a6a1f1dSLionel Sambuc.Em Important : 44*0a6a1f1dSLionel SambucThe functions 45*0a6a1f1dSLionel Sambuc.Fn elf_open 46*0a6a1f1dSLionel Sambucand 47*0a6a1f1dSLionel Sambuc.Fn elf_openmemory 48*0a6a1f1dSLionel Sambucare extensions to the ELF(3) API, for the internal use of the 49*0a6a1f1dSLionel SambucElftoolchain project. 50*0a6a1f1dSLionel SambucPortable applications should not use these functions. 51*0a6a1f1dSLionel Sambuc.Pp 52*0a6a1f1dSLionel SambucThe function 53*0a6a1f1dSLionel Sambuc.Fn elf_open 54*0a6a1f1dSLionel Sambucreturns an Elf descriptor opened with mode 55*0a6a1f1dSLionel Sambuc.Dv ELF_C_READ 56*0a6a1f1dSLionel Sambucfor the ELF object or 57*0a6a1f1dSLionel Sambuc.Xr ar 1 58*0a6a1f1dSLionel Sambucarchive referenced by the file descriptor in argument 59*0a6a1f1dSLionel Sambuc.Ar fd . 60*0a6a1f1dSLionel Sambuc.Pp 61*0a6a1f1dSLionel SambucThe function 62*0a6a1f1dSLionel Sambuc.Fn elf_openmemory 63*0a6a1f1dSLionel Sambucreturns an ELF descriptor opened with mode 64*0a6a1f1dSLionel Sambuc.Dv ELF_C_READ 65*0a6a1f1dSLionel Sambucfor the ELF object or 66*0a6a1f1dSLionel Sambuc.Xr ar 1 67*0a6a1f1dSLionel Sambucarchive contained in the memory area pointed to by the argument 68*0a6a1f1dSLionel Sambuc.Ar image . 69*0a6a1f1dSLionel SambucThe argument 70*0a6a1f1dSLionel Sambuc.Ar sz 71*0a6a1f1dSLionel Sambucspecifies the size of the memory area in bytes. 72*0a6a1f1dSLionel Sambuc.Sh COMPATIBILITY 73*0a6a1f1dSLionel SambucThese functions are non-standard extensions to the ELF(3) API set. 74*0a6a1f1dSLionel Sambuc.Pp 75*0a6a1f1dSLionel SambucThe behavior of these functions differs from their counterparts 76*0a6a1f1dSLionel Sambuc.Xr elf_begin 3 77*0a6a1f1dSLionel Sambucand 78*0a6a1f1dSLionel Sambuc.Xr elf_memory 3 79*0a6a1f1dSLionel Sambucin that these functions will successfully open malformed ELF objects 80*0a6a1f1dSLionel Sambucand 81*0a6a1f1dSLionel Sambuc.Xr ar 1 82*0a6a1f1dSLionel Sambucarchives, returning an Elf descriptor of type 83*0a6a1f1dSLionel Sambuc.Dv ELF_K_NONE . 84*0a6a1f1dSLionel Sambuc.Sh RETURN VALUES 85*0a6a1f1dSLionel SambucThe function returns a pointer to a ELF descriptor if successful, or 86*0a6a1f1dSLionel SambucNULL if an error occurred. 87*0a6a1f1dSLionel Sambuc.Sh ERRORS 88*0a6a1f1dSLionel SambucThese functions can fail with the following errors: 89*0a6a1f1dSLionel Sambuc.Bl -tag -width "[ELF_E_RESOURCE]" 90*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_ARGUMENT 91*0a6a1f1dSLionel SambucThe argument 92*0a6a1f1dSLionel Sambuc.Ar fd 93*0a6a1f1dSLionel Sambucwas of an unsupported file type. 94*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_ARGUMENT 95*0a6a1f1dSLionel SambucThe argument 96*0a6a1f1dSLionel Sambuc.Ar sz 97*0a6a1f1dSLionel Sambucwas zero, or the argument 98*0a6a1f1dSLionel Sambuc.Ar image 99*0a6a1f1dSLionel Sambucwas NULL. 100*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_IO 101*0a6a1f1dSLionel SambucThe file descriptor in argument 102*0a6a1f1dSLionel Sambuc.Ar fd 103*0a6a1f1dSLionel Sambucwas invalid. 104*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_IO 105*0a6a1f1dSLionel SambucThe file descriptor in argument 106*0a6a1f1dSLionel Sambuc.Ar fd 107*0a6a1f1dSLionel Sambuccould not be read. 108*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_RESOURCE 109*0a6a1f1dSLionel SambucAn out of memory condition was encountered. 110*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_SEQUENCE 111*0a6a1f1dSLionel SambucFunctions 112*0a6a1f1dSLionel Sambuc.Fn elf_open 113*0a6a1f1dSLionel Sambucor 114*0a6a1f1dSLionel Sambuc.Fn elf_openmemory 115*0a6a1f1dSLionel Sambucwas called before a working version was established with 116*0a6a1f1dSLionel Sambuc.Xr elf_version 3 . 117*0a6a1f1dSLionel Sambuc.El 118*0a6a1f1dSLionel Sambuc.Sh SEE ALSO 119*0a6a1f1dSLionel Sambuc.Xr elf 3 , 120*0a6a1f1dSLionel Sambuc.Xr elf_begin 3 , 121*0a6a1f1dSLionel Sambuc.Xr elf_errno 3 , 122*0a6a1f1dSLionel Sambuc.Xr elf_memory 3 , 123*0a6a1f1dSLionel Sambuc.Xr gelf 3 124