12de3b87aSKai Wang.\" Copyright (c) 2006-2008 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: gelf_newphdr.3 3743 2019-06-12 19:36:30Z jkoshy $ 252de3b87aSKai Wang.\" 26*d003e0d7SEd Maste.Dd June 12, 2019 272de3b87aSKai Wang.Dt GELF_NEWPHDR 3 28ae500c1fSEd Maste.Os 292de3b87aSKai Wang.Sh NAME 302de3b87aSKai Wang.Nm elf32_newphdr , 312de3b87aSKai Wang.Nm elf64_newphdr , 322de3b87aSKai Wang.Nm gelf_newphdr 332de3b87aSKai Wang.Nd allocate an ELF program header table 342de3b87aSKai Wang.Sh LIBRARY 352de3b87aSKai Wang.Lb libelf 362de3b87aSKai Wang.Sh SYNOPSIS 372de3b87aSKai Wang.In libelf.h 382de3b87aSKai Wang.Ft "Elf32_Phdr *" 392de3b87aSKai Wang.Fn elf32_newphdr "Elf *elf" "size_t count" 402de3b87aSKai Wang.Ft "Elf64_Phdr *" 412de3b87aSKai Wang.Fn elf64_newphdr "Elf *elf" "size_t count" 422de3b87aSKai Wang.In gelf.h 432de3b87aSKai Wang.Ft "void *" 442de3b87aSKai Wang.Fn gelf_newphdr "Elf *elf" "size_t count" 452de3b87aSKai Wang.Sh DESCRIPTION 462de3b87aSKai WangThese functions allocate an ELF Program Header table 472de3b87aSKai Wangfor an ELF descriptor. 482de3b87aSKai Wang.Vt Elf32_Phdr 492de3b87aSKai Wangand 502de3b87aSKai Wang.Vt Elf64_Phdr 512de3b87aSKai Wangdescriptors are described further in 522de3b87aSKai Wang.Xr elf 5 . 532de3b87aSKai Wang.Pp 542de3b87aSKai WangFunctions 552de3b87aSKai Wang.Fn elf32_newphdr 562de3b87aSKai Wangand 572de3b87aSKai Wang.Fn elf64_newphdr 582de3b87aSKai Wangallocate a table of 592de3b87aSKai Wang.Ar count 602de3b87aSKai Wang.Vt Elf32_Phdr 612de3b87aSKai Wangand 622de3b87aSKai Wang.Vt Elf64_Phdr 632de3b87aSKai Wangdescriptors respectively, 642de3b87aSKai Wangdiscarding any existing program header table 652de3b87aSKai Wangalready present in the ELF descriptor 662de3b87aSKai Wang.Ar elf . 672de3b87aSKai WangA value of zero for argument 682de3b87aSKai Wang.Ar count 692de3b87aSKai Wangmay be used to delete an existing program header table 702de3b87aSKai Wangfrom an ELF descriptor. 712de3b87aSKai Wang.Pp 722de3b87aSKai WangFunction 732de3b87aSKai Wang.Fn gelf_newphdr 742de3b87aSKai Wangwill return a table of 752de3b87aSKai Wang.Vt Elf32_Phdr 762de3b87aSKai Wangor 772de3b87aSKai Wang.Vt Elf64_Phdr 782de3b87aSKai Wangwith 792de3b87aSKai Wang.Ar count 802de3b87aSKai Wangelements depending on the ELF class of ELF descriptor 812de3b87aSKai Wang.Ar elf . 822de3b87aSKai Wang.Pp 832de3b87aSKai WangThe functions set the 842de3b87aSKai Wang.Dv ELF_F_DIRTY 852de3b87aSKai Wangflag on the program header table. 862de3b87aSKai WangAll members of the returned array of Phdr structures 872de3b87aSKai Wangwill be initialized to zero. 882de3b87aSKai Wang.Pp 892de3b87aSKai WangAfter a successful call to these functions, the pointer returned 902de3b87aSKai Wangby a prior call to 912de3b87aSKai Wang.Fn elf32_getphdr 922de3b87aSKai Wangor 932de3b87aSKai Wang.Fn elf64_getphdr 942de3b87aSKai Wangon the same descriptor 952de3b87aSKai Wang.Ar elf 962de3b87aSKai Wangwill no longer be valid. 972de3b87aSKai Wang.Sh RETURN VALUES 982de3b87aSKai WangThe functions a valid pointer if successful, or NULL in case an error 992de3b87aSKai Wangwas encountered. 100bee2765cSEd Maste.Sh COMPATIBILITY 101bee2765cSEd MasteThe 102bee2765cSEd Maste.Fn gelf_newphdr 103bee2765cSEd Mastefunction uses a type of 104bee2765cSEd Maste.Ft "void *" 105bee2765cSEd Mastefor its returned value. 106*d003e0d7SEd MasteThis differs from some other implementations of the 107*d003e0d7SEd Maste.Xr elf 3 108*d003e0d7SEd MasteAPI, which use an 109bee2765cSEd Maste.Ft "unsigned long" 110bee2765cSEd Mastereturn type. 1112de3b87aSKai Wang.Sh ERRORS 1122de3b87aSKai WangThese functions may fail with the following errors: 1132de3b87aSKai Wang.Bl -tag -width "[ELF_E_RESOURCE]" 1142de3b87aSKai Wang.It Bq Er ELF_E_ARGUMENT 1152de3b87aSKai WangArgument 1162de3b87aSKai Wang.Ar elf 1172de3b87aSKai Wangwas NULL. 1182de3b87aSKai Wang.It Bq Er ELF_E_ARGUMENT 1192de3b87aSKai WangArgument 1202de3b87aSKai Wang.Ar elf 1212de3b87aSKai Wangwas not a descriptor for an ELF object. 1222de3b87aSKai Wang.It Bq Er ELF_E_CLASS 1232de3b87aSKai WangELF descriptor 1242de3b87aSKai Wang.Ar elf 1252de3b87aSKai Wangwas of an unrecognized class. 1262de3b87aSKai Wang.It Bq Er ELF_E_RESOURCE 1272de3b87aSKai WangAn out of memory condition was detected. 1282de3b87aSKai Wang.It Bq Er ELF_E_SEQUENCE 1292de3b87aSKai WangAn executable header was not allocated for ELF descriptor 1302de3b87aSKai Wang.Ar elf 1312de3b87aSKai Wangbefore using these APIs. 1322de3b87aSKai Wang.El 1332de3b87aSKai Wang.Sh SEE ALSO 1342de3b87aSKai Wang.Xr elf 3 , 1352de3b87aSKai Wang.Xr elf32_getphdr 3 , 1362de3b87aSKai Wang.Xr elf32_newehdr 3 , 1372de3b87aSKai Wang.Xr elf64_getphdr 3 , 1382de3b87aSKai Wang.Xr elf64_newehdr 3 , 1392de3b87aSKai Wang.Xr elf_flagphdr 3 , 1402de3b87aSKai Wang.Xr elf_getphnum 3 , 1412de3b87aSKai Wang.Xr gelf 3 , 1422de3b87aSKai Wang.Xr gelf_getphdr 3 , 1432de3b87aSKai Wang.Xr gelf_newehdr 3 , 1442de3b87aSKai Wang.Xr elf 5 145