/ external / libelf / elf_open.3
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$ 
 25  .\"
 26  .Dd May 31, 2012
 27  .Os
 28  .Dt ELF_OPEN 3 
 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 ELF(3) API, for the internal use of the
 47  Elftoolchain project.
 48  Portable applications should not use these functions.
 49  .Pp
 50  The function
 51  .Fn elf_open
 52  returns an Elf descriptor opened with mode
 53  .Dv ELF_C_READ
 54  for the ELF object or
 55  .Xr ar 1
 56  archive referenced by the file descriptor in argument
 57  .Ar fd .
 58  .Pp
 59  The function
 60  .Fn elf_openmemory
 61  returns an ELF descriptor opened with mode
 62  .Dv ELF_C_READ
 63  for the ELF object or
 64  .Xr ar 1
 65  archive contained in the memory area pointed to by the argument
 66  .Ar image .
 67  The argument
 68  .Ar sz
 69  specifies the size of the memory area in bytes.
 70  .Sh COMPATIBILITY
 71  These functions are non-standard extensions to the ELF(3) API set.
 72  .Pp
 73  The behavior of these functions differs from their counterparts
 74  .Xr elf_begin 3
 75  and
 76  .Xr elf_memory 3
 77  in that these functions will successfully open malformed ELF objects
 78  and
 79  .Xr ar 1
 80  archives, returning an Elf descriptor of type
 81  .Dv ELF_K_NONE .
 82  .Sh RETURN VALUES
 83  The function returns a pointer to a ELF descriptor if successful, or
 84  NULL if an error occurred.
 85  .Sh ERRORS
 86  These functions can fail with the following errors:
 87  .Bl -tag -width "[ELF_E_RESOURCE]"
 88  .It Bq Er ELF_E_ARGUMENT
 89  The argument
 90  .Ar fd
 91  was of an unsupported file type.
 92  .It Bq Er ELF_E_ARGUMENT
 93  The argument
 94  .Ar sz
 95  was zero, or the argument
 96  .Ar image
 97  was NULL.
 98  .It Bq Er ELF_E_IO
 99  The file descriptor in argument
100  .Ar fd
101  was invalid.
102  .It Bq Er ELF_E_IO
103  The file descriptor in argument
104  .Ar fd
105  could not be read.
106  .It Bq Er ELF_E_RESOURCE
107  An out of memory condition was encountered.
108  .It Bq Er ELF_E_SEQUENCE
109  Functions
110  .Fn elf_open
111  or
112  .Fn elf_openmemory
113  was called before a working version was established with
114  .Xr elf_version 3 .
115  .El
116  .Sh SEE ALSO
117  .Xr elf 3 ,
118  .Xr elf_begin 3 ,
119  .Xr elf_errno 3 ,
120  .Xr elf_memory 3 ,
121  .Xr gelf 3