1*5ac3bc71Schristos.\" $NetBSD: gelf_getehdr.3,v 1.6 2024/03/03 17:37:34 christos Exp $ 2e81373b4Schristos.\" 39dd9d0cfSchristos.\" Copyright (c) 2006,2008 Joseph Koshy. All rights reserved. 49dd9d0cfSchristos.\" 59dd9d0cfSchristos.\" Redistribution and use in source and binary forms, with or without 69dd9d0cfSchristos.\" modification, are permitted provided that the following conditions 79dd9d0cfSchristos.\" are met: 89dd9d0cfSchristos.\" 1. Redistributions of source code must retain the above copyright 99dd9d0cfSchristos.\" notice, this list of conditions and the following disclaimer. 109dd9d0cfSchristos.\" 2. Redistributions in binary form must reproduce the above copyright 119dd9d0cfSchristos.\" notice, this list of conditions and the following disclaimer in the 129dd9d0cfSchristos.\" documentation and/or other materials provided with the distribution. 139dd9d0cfSchristos.\" 149dd9d0cfSchristos.\" This software is provided by Joseph Koshy ``as is'' and 159dd9d0cfSchristos.\" any express or implied warranties, including, but not limited to, the 169dd9d0cfSchristos.\" implied warranties of merchantability and fitness for a particular purpose 179dd9d0cfSchristos.\" are disclaimed. in no event shall Joseph Koshy be liable 189dd9d0cfSchristos.\" for any direct, indirect, incidental, special, exemplary, or consequential 199dd9d0cfSchristos.\" damages (including, but not limited to, procurement of substitute goods 209dd9d0cfSchristos.\" or services; loss of use, data, or profits; or business interruption) 219dd9d0cfSchristos.\" however caused and on any theory of liability, whether in contract, strict 229dd9d0cfSchristos.\" liability, or tort (including negligence or otherwise) arising in any way 239dd9d0cfSchristos.\" out of the use of this software, even if advised of the possibility of 249dd9d0cfSchristos.\" such damage. 259dd9d0cfSchristos.\" 263f622274Sjkoshy.\" Id: gelf_getehdr.3 3958 2022-03-12 14:31:32Z jkoshy 279dd9d0cfSchristos.\" 289dd9d0cfSchristos.Dd December 16, 2006 299dd9d0cfSchristos.Dt GELF_GETEHDR 3 30c5261b83Sjkoshy.Os 319dd9d0cfSchristos.Sh NAME 329dd9d0cfSchristos.Nm elf32_getehdr , 339dd9d0cfSchristos.Nm elf64_getehdr , 349dd9d0cfSchristos.Nm gelf_getehdr 359dd9d0cfSchristos.Nd retrieve the object file header 369dd9d0cfSchristos.Sh LIBRARY 379dd9d0cfSchristos.Lb libelf 389dd9d0cfSchristos.Sh SYNOPSIS 399dd9d0cfSchristos.In libelf.h 409dd9d0cfSchristos.Ft "Elf32_Ehdr *" 419dd9d0cfSchristos.Fn elf32_getehdr "Elf *elf" 429dd9d0cfSchristos.Ft "Elf64_Ehdr *" 439dd9d0cfSchristos.Fn elf64_getehdr "Elf *elf" 449dd9d0cfSchristos.In gelf.h 459dd9d0cfSchristos.Ft "GElf_Ehdr *" 469dd9d0cfSchristos.Fn gelf_getehdr "Elf *elf" "GElf_Ehdr *dst" 479dd9d0cfSchristos.Sh DESCRIPTION 489dd9d0cfSchristosThese functions retrieve the ELF object file 499dd9d0cfSchristosheader from the ELF descriptor 503f622274Sjkoshy.Fa elf 519dd9d0cfSchristosand return a translated header descriptor to their callers. 529dd9d0cfSchristos.Pp 539dd9d0cfSchristosFunctions 549dd9d0cfSchristos.Fn elf32_getehdr 559dd9d0cfSchristosand 569dd9d0cfSchristos.Fn elf64_getehdr 579dd9d0cfSchristosreturn a pointer to the appropriate class-specific header descriptor 589dd9d0cfSchristosif it exists in the file referenced by descriptor 593f622274Sjkoshy.Fa elf . 609dd9d0cfSchristosThese functions return 619dd9d0cfSchristos.Dv NULL 629dd9d0cfSchristosif an ELF header was not found in file 633f622274Sjkoshy.Fa elf . 649dd9d0cfSchristos.Pp 659dd9d0cfSchristosFunction 669dd9d0cfSchristos.Fn gelf_getehdr 679dd9d0cfSchristosstores a translated copy of the header for ELF file 683f622274Sjkoshy.Fa elf 699dd9d0cfSchristosinto the descriptor pointed to by argument 703f622274Sjkoshy.Fa dst . 719dd9d0cfSchristosIt returns argument 723f622274Sjkoshy.Fa dst 739dd9d0cfSchristosif successful or 749dd9d0cfSchristos.Dv NULL 759dd9d0cfSchristosin case of failure. 769dd9d0cfSchristos.Sh RETURN VALUES 779dd9d0cfSchristosThese functions return a pointer to a translated header descriptor 78c5261b83Sjkoshyif successful, or 79c5261b83Sjkoshy.Dv NULL 80c5261b83Sjkoshyon failure. 819dd9d0cfSchristos.Sh ERRORS 829dd9d0cfSchristosThese functions can fail with the following errors: 839dd9d0cfSchristos.Bl -tag -width "[ELF_E_RESOURCE]" 849dd9d0cfSchristos.It Bq Er ELF_E_ARGUMENT 859dd9d0cfSchristosThe argument 863f622274Sjkoshy.Fa elf 879dd9d0cfSchristoswas null. 889dd9d0cfSchristos.It Bq Er ELF_E_ARGUMENT 899dd9d0cfSchristosArgument 903f622274Sjkoshy.Fa elf 919dd9d0cfSchristoswas not a descriptor for an ELF file. 929dd9d0cfSchristos.It Bq Er ELF_E_ARGUMENT 939dd9d0cfSchristosThe elf class of descriptor 943f622274Sjkoshy.Fa elf 959dd9d0cfSchristoswas not recognized. 969dd9d0cfSchristos.It Bq Er ELF_E_ARGUMENT 979dd9d0cfSchristosArgument 983f622274Sjkoshy.Fa dst 999dd9d0cfSchristoswas null. 1009dd9d0cfSchristos.It Bq Er ELF_E_CLASS 1019dd9d0cfSchristosThe ELF class of descriptor 1023f622274Sjkoshy.Fa elf 1039dd9d0cfSchristosdid not match that of the API function being called. 1049dd9d0cfSchristos.It Bq Er ELF_E_HEADER 1059dd9d0cfSchristosELF descriptor 1063f622274Sjkoshy.Fa elf 1079dd9d0cfSchristosdoes not have an associated header. 1089dd9d0cfSchristos.It Bq Er ELF_E_RESOURCE 1099dd9d0cfSchristosAn out of memory condition was detected during execution. 1109dd9d0cfSchristos.It Bq Er ELF_E_SECTION 1119dd9d0cfSchristosThe ELF descriptor in argument 1123f622274Sjkoshy.Fa elf 1139dd9d0cfSchristosdid not adhere to the conventions used for extended numbering. 1149dd9d0cfSchristos.It Bq Er ELF_E_VERSION 1159dd9d0cfSchristosThe ELF descriptor 1163f622274Sjkoshy.Fa elf 1179dd9d0cfSchristoshad an unsupported ELF version number. 1189dd9d0cfSchristos.El 1199dd9d0cfSchristos.Sh SEE ALSO 1209dd9d0cfSchristos.Xr elf 3 , 1219dd9d0cfSchristos.Xr elf32_newehdr 3 , 1229dd9d0cfSchristos.Xr elf64_newehdr 3 , 1239dd9d0cfSchristos.Xr elf_flagehdr 3 , 1249dd9d0cfSchristos.Xr elf_getident 3 , 1259dd9d0cfSchristos.Xr gelf 3 , 1269dd9d0cfSchristos.Xr gelf_newehdr 3 , 1279dd9d0cfSchristos.Xr elf 5 128