xref: /freebsd/contrib/elftoolchain/libelf/elf_getshdrnum.3 (revision 2de3b87a120614a3b053be7dd845b72f1e9ce804)
1*2de3b87aSKai Wang.\" Copyright (c) 2006,2008 Joseph Koshy.  All rights reserved.
2*2de3b87aSKai Wang.\"
3*2de3b87aSKai Wang.\" Redistribution and use in source and binary forms, with or without
4*2de3b87aSKai Wang.\" modification, are permitted provided that the following conditions
5*2de3b87aSKai Wang.\" are met:
6*2de3b87aSKai Wang.\" 1. Redistributions of source code must retain the above copyright
7*2de3b87aSKai Wang.\"    notice, this list of conditions and the following disclaimer.
8*2de3b87aSKai Wang.\" 2. Redistributions in binary form must reproduce the above copyright
9*2de3b87aSKai Wang.\"    notice, this list of conditions and the following disclaimer in the
10*2de3b87aSKai Wang.\"    documentation and/or other materials provided with the distribution.
11*2de3b87aSKai Wang.\"
12*2de3b87aSKai Wang.\" This software is provided by Joseph Koshy ``as is'' and
13*2de3b87aSKai Wang.\" any express or implied warranties, including, but not limited to, the
14*2de3b87aSKai Wang.\" implied warranties of merchantability and fitness for a particular purpose
15*2de3b87aSKai Wang.\" are disclaimed.  in no event shall Joseph Koshy be liable
16*2de3b87aSKai Wang.\" for any direct, indirect, incidental, special, exemplary, or consequential
17*2de3b87aSKai Wang.\" damages (including, but not limited to, procurement of substitute goods
18*2de3b87aSKai Wang.\" or services; loss of use, data, or profits; or business interruption)
19*2de3b87aSKai Wang.\" however caused and on any theory of liability, whether in contract, strict
20*2de3b87aSKai Wang.\" liability, or tort (including negligence or otherwise) arising in any way
21*2de3b87aSKai Wang.\" out of the use of this software, even if advised of the possibility of
22*2de3b87aSKai Wang.\" such damage.
23*2de3b87aSKai Wang.\"
24*2de3b87aSKai Wang.\" $Id: elf_getshdrnum.3 467 2009-08-05 18:18:49Z jkoshy $
25*2de3b87aSKai Wang.\"
26*2de3b87aSKai Wang.Dd August 4, 2009
27*2de3b87aSKai Wang.Os
28*2de3b87aSKai Wang.Dt ELF_GETSHDRNUM 3
29*2de3b87aSKai Wang.Sh NAME
30*2de3b87aSKai Wang.Nm elf_getshdrnum
31*2de3b87aSKai Wang.Nd return the number of sections in an ELF file
32*2de3b87aSKai Wang.Sh LIBRARY
33*2de3b87aSKai Wang.Lb libelf
34*2de3b87aSKai Wang.Sh SYNOPSIS
35*2de3b87aSKai Wang.In libelf.h
36*2de3b87aSKai Wang.Ft int
37*2de3b87aSKai Wang.Fn elf_getshdrnum "Elf *elf" "size_t *shnum"
38*2de3b87aSKai Wang.Sh DESCRIPTION
39*2de3b87aSKai WangFunction
40*2de3b87aSKai Wang.Fn elf_getshdrnum
41*2de3b87aSKai Wangretrieves the number of ELF sections associated with descriptor
42*2de3b87aSKai Wang.Ar elf
43*2de3b87aSKai Wangand stores it into the location pointed to by argument
44*2de3b87aSKai Wang.Ar shnum .
45*2de3b87aSKai Wang.Pp
46*2de3b87aSKai WangThis routine allows applications to uniformly process both normal ELF
47*2de3b87aSKai Wangobjects, and ELF objects that use extended section numbering.
48*2de3b87aSKai Wang.Pp
49*2de3b87aSKai Wang.Sh RETURN VALUES
50*2de3b87aSKai WangFunction
51*2de3b87aSKai Wang.Fn elf_getshdrnum
52*2de3b87aSKai Wangreturns zero value if successful, or -1 in case of an error.
53*2de3b87aSKai Wang.Sh ERRORS
54*2de3b87aSKai WangFunction
55*2de3b87aSKai Wang.Fn elf_getshdrnum
56*2de3b87aSKai Wangcan fail with the following errors:
57*2de3b87aSKai Wang.Bl -tag -width "[ELF_E_RESOURCE]"
58*2de3b87aSKai Wang.It Bq Er ELF_E_ARGUMENT
59*2de3b87aSKai WangA NULL value was passed in for argument
60*2de3b87aSKai Wang.Ar elf .
61*2de3b87aSKai Wang.It Bq Er ELF_E_ARGUMENT
62*2de3b87aSKai WangArgument
63*2de3b87aSKai Wang.Ar elf
64*2de3b87aSKai Wangwas not for an ELF file.
65*2de3b87aSKai Wang.It Bq Er ELF_E_ARGUMENT
66*2de3b87aSKai WangArgument
67*2de3b87aSKai Wang.Ar elf
68*2de3b87aSKai Wanglacks an ELF Executable header.
69*2de3b87aSKai Wang.El
70*2de3b87aSKai Wang.Sh SEE ALSO
71*2de3b87aSKai Wang.Xr elf 3 ,
72*2de3b87aSKai Wang.Xr elf32_getehdr 3 ,
73*2de3b87aSKai Wang.Xr elf64_getehdr 3 ,
74*2de3b87aSKai Wang.Xr elf_getident 3 ,
75*2de3b87aSKai Wang.Xr elf_getphdrnum 3 ,
76*2de3b87aSKai Wang.Xr elf_getshdrstrndx 3 ,
77*2de3b87aSKai Wang.Xr gelf 3 ,
78*2de3b87aSKai Wang.Xr gelf_getehdr 3
79