xref: /freebsd/contrib/elftoolchain/libelf/elf_strptr.3 (revision 3c4ba5f55438f7afd4f4b0b56f88f2bb505fd6a6)
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: elf_strptr.3 3639 2018-10-14 14:07:02Z jkoshy $
25.\"
26.Dd December 16, 2006
27.Dt ELF_STRPTR 3
28.Os
29.Sh NAME
30.Nm elf_strptr
31.Nd retrieve a string pointer in a string table
32.Sh LIBRARY
33.Lb libelf
34.Sh SYNOPSIS
35.In libelf.h
36.Ft "char *"
37.Fn elf_strptr "Elf *elf" "size_t scndx" "size_t stroffset"
38.Sh DESCRIPTION
39Function
40.Fn elf_strptr
41allows an application to convert a string table offset to a string
42pointer, correctly translating the offset in the presence
43of multiple
44.Vt Elf_Data
45descriptors covering the contents of the section.
46.Pp
47Argument
48.Ar elf
49is a descriptor for an ELF object.
50Argument
51.Ar scndx
52is the section index for an ELF string table.
53Argument
54.Ar stroffset
55is the index of the desired string in the string
56table.
57.Sh RETURN VALUES
58Function
59.Fn elf_strptr
60returns a valid pointer on success or NULL in case an error was
61encountered.
62.Sh ERRORS
63.Bl -tag -width "[ELF_E_RESOURCE]"
64.It Bq Er ELF_E_ARGUMENT
65Argument
66.Ar elf
67was NULL
68.It Bq Er ELF_E_ARGUMENT
69Argument
70.Ar elf
71was not a descriptor for an ELF object.
72.It Bq Er ELF_E_ARGUMENT
73Argument
74.Ar scndx
75was not the section index for a string table.
76.It Bq Er ELF_E_ARGUMENT
77Argument
78.Ar stroffset
79exceeded the size of the string table.
80.It Bq Er ELF_E_ARGUMENT
81Argument
82.Ar stroffset
83index an unallocated region of the string table.
84.It Bq Er ELF_E_DATA
85Offset
86.Ar stroffset
87indexed a region that was not covered by any Elf_Data
88descriptor.
89.It Bq Er ELF_E_DATA
90An erroneous
91.Vt Elf_Data
92descriptor was part of the section specified by argument
93.Ar scndx .
94.It Bq Er ELF_E_HEADER
95ELF descriptor
96.Ar elf
97contained an invalid section header.
98.It Bq Er ELF_E_RESOURCE
99An out of memory condition was detected.
100.It Bq Er ELF_E_SECTION
101Section
102.Ar scndx
103contained a malformed section header.
104.It Bq Er ELF_E_SECTION
105The ELF descriptor in argument
106.Ar elf
107did not adhere to the conventions used for extended numbering.
108.El
109.Sh SEE ALSO
110.Xr elf 3 ,
111.Xr elf32_getshdr 3 ,
112.Xr elf64_getshdr 3 ,
113.Xr elf_getdata 3 ,
114.Xr elf_rawdata 3 ,
115.Xr gelf 3 ,
116.Xr gelf_getshdr 3
117