xref: /freebsd/contrib/elftoolchain/libelf/gelf_getshdr.3 (revision 4c1a82cea504df7a79f5bd8f7d0a41cacccff16e)
1.\" Copyright (c) 2006,2008 Joseph Koshy.  All rights reserved.
2.\"
3.\" Redistribution and use in source and binary forms, with or without
4.\" modification, are permitted provided that the following conditions
5.\" are met:
6.\" 1. Redistributions of source code must retain the above copyright
7.\"    notice, this list of conditions and the following disclaimer.
8.\" 2. Redistributions in binary form must reproduce the above copyright
9.\"    notice, this list of conditions and the following disclaimer in the
10.\"    documentation and/or other materials provided with the distribution.
11.\"
12.\" This software is provided by Joseph Koshy ``as is'' and
13.\" any express or implied warranties, including, but not limited to, the
14.\" implied warranties of merchantability and fitness for a particular purpose
15.\" are disclaimed.  in no event shall Joseph Koshy be liable
16.\" for any direct, indirect, incidental, special, exemplary, or consequential
17.\" damages (including, but not limited to, procurement of substitute goods
18.\" or services; loss of use, data, or profits; or business interruption)
19.\" however caused and on any theory of liability, whether in contract, strict
20.\" liability, or tort (including negligence or otherwise) arising in any way
21.\" out of the use of this software, even if advised of the possibility of
22.\" such damage.
23.\"
24.\" $Id: gelf_getshdr.3 3639 2018-10-14 14:07:02Z jkoshy $
25.\"
26.Dd August 27, 2006
27.Dt GELF_GETSHDR 3
28.Os
29.Sh NAME
30.Nm elf32_getshdr ,
31.Nm elf64_getshdr ,
32.Nm gelf_getshdr
33.Nd retrieve the class-dependent section header
34.Sh LIBRARY
35.Lb libelf
36.Sh SYNOPSIS
37.In libelf.h
38.Ft "Elf32_Shdr *"
39.Fn elf32_getshdr "Elf_Scn *scn"
40.Ft "Elf64_Shdr *"
41.Fn elf64_getshdr "Elf_Scn *scn"
42.In gelf.h
43.Ft "GElf_Shdr *"
44.Fn gelf_getshdr "Elf_Scn *scn" "GElf_Shdr *shdr"
45.Sh DESCRIPTION
46These functions return a pointer to the ELF Section Header data
47structure associated with section descriptor
48.Ar scn .
49.Pp
50Function
51.Fn elf32_getshdr
52retrieves a pointer to an
53.Vt Elf32_Shdr
54structure.
55Section descriptor
56.Ar scn
57must be associated with an ELF descriptor of class
58.Dv ELFCLASS32 .
59.Pp
60Function
61.Fn elf64_getshdr
62retrieves a pointer to an
63.Vt Elf64_Shdr
64structure.
65Section descriptor
66.Ar scn
67must be associated with an ELF descriptor of class
68.Dv ELFCLASS64 .
69.Pp
70Function
71.Fn gelf_getshdr
72copies the values in the section header associated with argument
73.Ar scn
74to the structure pointed to be argument
75.Ar dst .
76The
77.Vt GElf_Shdr
78data structure is described in
79.Xr gelf 3 .
80.Sh RETURN VALUES
81Functions
82.Fn elf32_getshdr
83and
84.Fn elf64_getshdr
85return a valid pointer to the appropriate section header on success
86or NULL if an error was encountered.
87.Pp
88Function
89.Fn gelf_getshdr
90returns argument
91.Ar dst
92if successful, or NULL if an error was encountered.
93.Sh ERRORS
94These functions may fail with the following errors:
95.Bl -tag -width "[ELF_E_RESOURCE]"
96.It Bq Er ELF_E_ARGUMENT
97Arguments
98.Ar scn
99or
100.Ar shdr
101were NULL.
102.It Bq Er ELF_E_ARGUMENT
103Argument
104.Ar scn
105was not associated a descriptor for an ELF object.
106.It Bq Er ELF_E_CLASS
107The ELF class associated with the section descriptor
108.Ar scn
109did not match the class expected by the API.
110.El
111.Sh SEE ALSO
112.Xr elf 3 ,
113.Xr elf_getscn 3 ,
114.Xr gelf 3 ,
115.Xr gelf_update_shdr 3
116