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