xref: /netbsd-src/external/bsd/elftoolchain/dist/libelf/elf_getphnum.3 (revision 5ac3bc719ce6e70593039505b491894133237d12)
1*5ac3bc71Schristos.\"	$NetBSD: elf_getphnum.3,v 1.6 2024/03/03 17:37:33 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: elf_getphnum.3 3956 2022-03-12 12:39:30Z jkoshy
279dd9d0cfSchristos.\"
289dd9d0cfSchristos.Dd August 5, 2009
299dd9d0cfSchristos.Dt ELF_GETPHNUM 3
30c5261b83Sjkoshy.Os
319dd9d0cfSchristos.Sh NAME
329dd9d0cfSchristos.Nm elf_getphnum
339dd9d0cfSchristos.Nd return the number of program headers in an ELF file
349dd9d0cfSchristos.Sh LIBRARY
359dd9d0cfSchristos.Lb libelf
369dd9d0cfSchristos.Sh SYNOPSIS
379dd9d0cfSchristos.In libelf.h
389dd9d0cfSchristos.Ft int
399dd9d0cfSchristos.Fn elf_getphnum "Elf *elf" "size_t *phnum"
409dd9d0cfSchristos.Sh DESCRIPTION
419dd9d0cfSchristosThis function is deprecated.
429dd9d0cfSchristosPlease use function
439dd9d0cfSchristos.Xr elf_getphdrnum 3
449dd9d0cfSchristosinstead.
459dd9d0cfSchristos.Pp
469dd9d0cfSchristosFunction
479dd9d0cfSchristos.Fn elf_getphnum
489dd9d0cfSchristosretrieves the number of ELF program headers associated with descriptor
493f622274Sjkoshy.Fa elf
509dd9d0cfSchristosand stores it into the location pointed to by argument
513f622274Sjkoshy.Fa phnum .
529dd9d0cfSchristos.Pp
539dd9d0cfSchristosThis routine allows applications to uniformly process both normal ELF
549dd9d0cfSchristosobjects and ELF objects that use extended numbering.
559dd9d0cfSchristos.Sh RETURN VALUES
569dd9d0cfSchristosFunction
579dd9d0cfSchristos.Fn elf_getphnum
589dd9d0cfSchristosreturns a non-zero value if successful, or zero in case of an
599dd9d0cfSchristoserror.
609dd9d0cfSchristos.Sh ERRORS
619dd9d0cfSchristosFunction
629dd9d0cfSchristos.Fn elf_getphnum
639dd9d0cfSchristoscan fail with the following errors:
649dd9d0cfSchristos.Bl -tag -width "[ELF_E_RESOURCE]"
659dd9d0cfSchristos.It Bq Er ELF_E_ARGUMENT
66c5261b83SjkoshyA
67c5261b83Sjkoshy.Dv NULL
68c5261b83Sjkoshyvalue was passed in for argument
693f622274Sjkoshy.Fa elf .
709dd9d0cfSchristos.It Bq Er ELF_E_ARGUMENT
719dd9d0cfSchristosArgument
723f622274Sjkoshy.Fa elf
739dd9d0cfSchristoswas not for an ELF file.
749dd9d0cfSchristos.It Bq Er ELF_E_ARGUMENT
759dd9d0cfSchristosArgument
763f622274Sjkoshy.Fa elf
779dd9d0cfSchristoslacks an ELF Executable Header.
789dd9d0cfSchristos.It Bq Er ELF_E_HEADER
799dd9d0cfSchristosThe ELF Executable Header associated with argument
803f622274Sjkoshy.Fa elf
819dd9d0cfSchristoswas corrupt.
829dd9d0cfSchristos.It Bq Er ELF_E_SECTION
839dd9d0cfSchristosThe section header at index
849dd9d0cfSchristos.Dv SHN_UNDEF
859dd9d0cfSchristoswas corrupt.
869dd9d0cfSchristos.El
879dd9d0cfSchristos.Sh SEE ALSO
889dd9d0cfSchristos.Xr elf 3 ,
899dd9d0cfSchristos.Xr elf32_getehdr 3 ,
909dd9d0cfSchristos.Xr elf64_getehdr 3 ,
919dd9d0cfSchristos.Xr elf_getident 3 ,
929dd9d0cfSchristos.Xr elf_getphdrnum 3 ,
939dd9d0cfSchristos.Xr elf_getshdrnum 3 ,
949dd9d0cfSchristos.Xr elf_getshdrstrndx 3 ,
959dd9d0cfSchristos.Xr gelf 3 ,
969dd9d0cfSchristos.Xr gelf_getehdr 3
97