xref: /netbsd-src/external/bsd/elftoolchain/dist/libelf/elf_strptr.3 (revision 5ac3bc719ce6e70593039505b491894133237d12)
1.\"	$NetBSD: elf_strptr.3,v 1.6 2024/03/03 17:37:33 christos Exp $
2.\"
3.\" Copyright (c) 2006,2008 Joseph Koshy.  All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" This software is provided by Joseph Koshy ``as is'' and
15.\" any express or implied warranties, including, but not limited to, the
16.\" implied warranties of merchantability and fitness for a particular purpose
17.\" are disclaimed.  in no event shall Joseph Koshy be liable
18.\" for any direct, indirect, incidental, special, exemplary, or consequential
19.\" damages (including, but not limited to, procurement of substitute goods
20.\" or services; loss of use, data, or profits; or business interruption)
21.\" however caused and on any theory of liability, whether in contract, strict
22.\" liability, or tort (including negligence or otherwise) arising in any way
23.\" out of the use of this software, even if advised of the possibility of
24.\" such damage.
25.\"
26.\" Id: elf_strptr.3 3957 2022-03-12 14:11:52Z jkoshy
27.\"
28.Dd December 16, 2006
29.Dt ELF_STRPTR 3
30.Os
31.Sh NAME
32.Nm elf_strptr
33.Nd retrieve a string pointer in a string table
34.Sh LIBRARY
35.Lb libelf
36.Sh SYNOPSIS
37.In libelf.h
38.Ft "char *"
39.Fn elf_strptr "Elf *elf" "size_t scndx" "size_t stroffset"
40.Sh DESCRIPTION
41Function
42.Fn elf_strptr
43allows an application to convert a string table offset to a string
44pointer, correctly translating the offset in the presence
45of multiple
46.Vt Elf_Data
47descriptors covering the contents of the section.
48.Pp
49Argument
50.Fa elf
51is a descriptor for an ELF object.
52Argument
53.Fa scndx
54is the section index for an ELF string table.
55Argument
56.Fa stroffset
57is the index of the desired string in the string
58table.
59.Sh RETURN VALUES
60Function
61.Fn elf_strptr
62returns a valid pointer on success or
63.Dv NULL
64in case an error was encountered.
65.Sh ERRORS
66.Bl -tag -width "[ELF_E_RESOURCE]"
67.It Bq Er ELF_E_ARGUMENT
68Argument
69.Fa elf
70was
71.Dv NULL .
72.It Bq Er ELF_E_ARGUMENT
73Argument
74.Fa elf
75was not a descriptor for an ELF object.
76.It Bq Er ELF_E_ARGUMENT
77Argument
78.Fa scndx
79was not the section index for a string table.
80.It Bq Er ELF_E_ARGUMENT
81Argument
82.Fa stroffset
83exceeded the size of the string table.
84.It Bq Er ELF_E_ARGUMENT
85Argument
86.Fa stroffset
87index an unallocated region of the string table.
88.It Bq Er ELF_E_DATA
89Offset
90.Fa stroffset
91indexed a region that was not covered by any Elf_Data
92descriptor.
93.It Bq Er ELF_E_DATA
94An erroneous
95.Vt Elf_Data
96descriptor was part of the section specified by argument
97.Fa scndx .
98.It Bq Er ELF_E_HEADER
99ELF descriptor
100.Fa elf
101contained an invalid section header.
102.It Bq Er ELF_E_RESOURCE
103An out of memory condition was detected.
104.It Bq Er ELF_E_SECTION
105Section
106.Fa scndx
107contained a malformed section header.
108.It Bq Er ELF_E_SECTION
109The ELF descriptor in argument
110.Fa elf
111did not adhere to the conventions used for extended numbering.
112.El
113.Sh SEE ALSO
114.Xr elf 3 ,
115.Xr elf32_getshdr 3 ,
116.Xr elf64_getshdr 3 ,
117.Xr elf_getdata 3 ,
118.Xr elf_rawdata 3 ,
119.Xr gelf 3 ,
120.Xr gelf_getshdr 3
121