1*0a6a1f1dSLionel Sambuc.\" $NetBSD: gelf_getphdr.3,v 1.2 2014/03/09 16:58:04 christos Exp $ 2*0a6a1f1dSLionel Sambuc.\" 3*0a6a1f1dSLionel Sambuc.\" Copyright (c) 2006-2008 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: gelf_getphdr.3 189 2008-07-20 10:38:08Z jkoshy 27*0a6a1f1dSLionel Sambuc.\" 28*0a6a1f1dSLionel Sambuc.Dd October 21, 2007 29*0a6a1f1dSLionel Sambuc.Os 30*0a6a1f1dSLionel Sambuc.Dt GELF_GETPHDR 3 31*0a6a1f1dSLionel Sambuc.Sh NAME 32*0a6a1f1dSLionel Sambuc.Nm elf32_getphdr , 33*0a6a1f1dSLionel Sambuc.Nm elf64_getphdr , 34*0a6a1f1dSLionel Sambuc.Nm gelf_getphdr 35*0a6a1f1dSLionel Sambuc.Nd retrieve an ELF program header table 36*0a6a1f1dSLionel Sambuc.Sh LIBRARY 37*0a6a1f1dSLionel Sambuc.Lb libelf 38*0a6a1f1dSLionel Sambuc.Sh SYNOPSIS 39*0a6a1f1dSLionel Sambuc.In libelf.h 40*0a6a1f1dSLionel Sambuc.Ft "Elf32_Phdr *" 41*0a6a1f1dSLionel Sambuc.Fn elf32_getphdr "Elf *elf" 42*0a6a1f1dSLionel Sambuc.Ft "Elf64_Phdr *" 43*0a6a1f1dSLionel Sambuc.Fn elf64_getphdr "Elf *elf" 44*0a6a1f1dSLionel Sambuc.In gelf.h 45*0a6a1f1dSLionel Sambuc.Ft "GElf_Phdr *" 46*0a6a1f1dSLionel Sambuc.Fn gelf_getphdr "Elf *elf" "int index" "GElf_Phdr *dst" 47*0a6a1f1dSLionel Sambuc.Sh DESCRIPTION 48*0a6a1f1dSLionel SambucThese functions retrieve and translate ELF program header information 49*0a6a1f1dSLionel Sambucfrom an ELF descriptor, if this information exists. 50*0a6a1f1dSLionel Sambuc.Pp 51*0a6a1f1dSLionel SambucFunctions 52*0a6a1f1dSLionel Sambuc.Fn elf32_getphdr 53*0a6a1f1dSLionel Sambucand 54*0a6a1f1dSLionel Sambuc.Fn elf64_getphdr 55*0a6a1f1dSLionel Sambucreturn a pointer to an array of translated 56*0a6a1f1dSLionel Sambuc.Vt Elf32_Phdr 57*0a6a1f1dSLionel Sambucand 58*0a6a1f1dSLionel Sambuc.Vt Elf64_Phdr 59*0a6a1f1dSLionel Sambucdescriptors respectively. 60*0a6a1f1dSLionel SambucThese descriptors are described in 61*0a6a1f1dSLionel Sambuc.Xr elf 5 . 62*0a6a1f1dSLionel SambucThe number of entries in this array may be determined using the 63*0a6a1f1dSLionel Sambuc.Xr elf_getphnum 3 64*0a6a1f1dSLionel Sambucfunction. 65*0a6a1f1dSLionel Sambuc.Pp 66*0a6a1f1dSLionel SambucFunction 67*0a6a1f1dSLionel Sambuc.Fn gelf_getphdr 68*0a6a1f1dSLionel Sambucwill retrieve the program header table entry at index 69*0a6a1f1dSLionel Sambuc.Ar index 70*0a6a1f1dSLionel Sambucfrom ELF descriptor 71*0a6a1f1dSLionel Sambuc.Ar elf. 72*0a6a1f1dSLionel SambucThe translated program header table entry will be written to the 73*0a6a1f1dSLionel Sambucaddress pointed to be argument 74*0a6a1f1dSLionel Sambuc.Ar dst . 75*0a6a1f1dSLionel Sambuc.Pp 76*0a6a1f1dSLionel SambucApplications may inform the library of modifications to a program header table entry 77*0a6a1f1dSLionel Sambucby using the 78*0a6a1f1dSLionel Sambuc.Xr elf_flagphdr 3 79*0a6a1f1dSLionel SambucAPI. 80*0a6a1f1dSLionel SambucApplications using the 81*0a6a1f1dSLionel Sambuc.Xr gelf 3 82*0a6a1f1dSLionel Sambucinterface need to use the 83*0a6a1f1dSLionel Sambuc.Xr gelf_update_phdr 3 84*0a6a1f1dSLionel SambucAPI to copy modifications to a program header entry back to the underlying 85*0a6a1f1dSLionel SambucELF descriptor. 86*0a6a1f1dSLionel Sambuc.Sh RETURN VALUES 87*0a6a1f1dSLionel SambucThe functions a valid pointer if successful, or NULL in case an error 88*0a6a1f1dSLionel Sambucwas encountered. 89*0a6a1f1dSLionel Sambuc.Sh ERRORS 90*0a6a1f1dSLionel SambucThese functions may fail with the following errors: 91*0a6a1f1dSLionel Sambuc.Bl -tag -width "[ELF_E_RESOURCE]" 92*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_ARGUMENT 93*0a6a1f1dSLionel SambucArgument 94*0a6a1f1dSLionel Sambuc.Ar elf 95*0a6a1f1dSLionel Sambucwas NULL. 96*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_ARGUMENT 97*0a6a1f1dSLionel SambucArgument 98*0a6a1f1dSLionel Sambuc.Ar elf 99*0a6a1f1dSLionel Sambucwas not a descriptor for an ELF object. 100*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_ARGUMENT 101*0a6a1f1dSLionel SambucArgument 102*0a6a1f1dSLionel Sambuc.Ar dst 103*0a6a1f1dSLionel Sambucwas NULL. 104*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_ARGUMENT 105*0a6a1f1dSLionel SambucIndex 106*0a6a1f1dSLionel Sambuc.Ar index 107*0a6a1f1dSLionel Sambucwas out of range. 108*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_CLASS 109*0a6a1f1dSLionel SambucThe class of ELF descriptor 110*0a6a1f1dSLionel Sambuc.Ar elf 111*0a6a1f1dSLionel Sambucdid not match the expected class of the function being called. 112*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_HEADER 113*0a6a1f1dSLionel SambucELF descriptor 114*0a6a1f1dSLionel Sambuc.Ar elf 115*0a6a1f1dSLionel Sambucdid not possess an executable header. 116*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_HEADER 117*0a6a1f1dSLionel SambucELF descriptor 118*0a6a1f1dSLionel Sambuc.Ar elf 119*0a6a1f1dSLionel Sambuchad a corrupt executable header. 120*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_RESOURCE 121*0a6a1f1dSLionel SambucAn out of memory condition was detected. 122*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_SECTION 123*0a6a1f1dSLionel SambucThe ELF descriptor in argument 124*0a6a1f1dSLionel Sambuc.Ar elf 125*0a6a1f1dSLionel Sambucdid not adhere to the conventions used for extended numbering. 126*0a6a1f1dSLionel Sambuc.It Bq Er ELF_VERSION 127*0a6a1f1dSLionel SambucELF descriptor 128*0a6a1f1dSLionel Sambuc.Ar elf 129*0a6a1f1dSLionel Sambucwas of an unsupported version. 130*0a6a1f1dSLionel Sambuc.El 131*0a6a1f1dSLionel Sambuc.Sh SEE ALSO 132*0a6a1f1dSLionel Sambuc.Xr elf 3 , 133*0a6a1f1dSLionel Sambuc.Xr elf32_getehdr 3 , 134*0a6a1f1dSLionel Sambuc.Xr elf32_newphdr 3 , 135*0a6a1f1dSLionel Sambuc.Xr elf64_getehdr 3 , 136*0a6a1f1dSLionel Sambuc.Xr elf64_newphdr 3 , 137*0a6a1f1dSLionel Sambuc.Xr elf_flagphdr 3 , 138*0a6a1f1dSLionel Sambuc.Xr elf_getphnum 3 , 139*0a6a1f1dSLionel Sambuc.Xr gelf 3 , 140*0a6a1f1dSLionel Sambuc.Xr gelf_getehdr 3 , 141*0a6a1f1dSLionel Sambuc.Xr gelf_newphdr 3 , 142*0a6a1f1dSLionel Sambuc.Xr gelf_update_phdr 3 , 143*0a6a1f1dSLionel Sambuc.Xr elf 5 144