2 .\" Copyright 1989 AT&T Copyright (c) 2001, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH ELF_STRPTR 3ELF "Jul 11, 2001"
8 elf_strptr \- make a string pointer
12 cc [ \fIflag\fR ... ] \fIfile\fR ... \fB-lelf\fR [ \fIlibrary\fR ... ]
15 \fBchar *\fR\fBelf_strptr\fR(\fBElf *\fR\fIelf\fR, \fBsize_t\fR \fIsection\fR, \fBsize_t\fR \fIoffset\fR);
21 The \fBelf_strptr()\fR function converts a string section \fIoffset\fR to a
22 string pointer. \fIelf\fR identifies the file in which the string section
23 resides, and \fIsection\fR identifies the section table index for the strings.
24 \fBelf_strptr()\fR normally returns a pointer to a string, but it returns a
25 null pointer when \fIelf\fR is null, \fIsection\fR is invalid or is not a
26 section of type \fBSHT_STRTAB\fR, the section data cannot be obtained,
27 \fIoffset\fR is invalid, or an error occurs.
30 \fBExample 1 \fRA sample program of calling \fBelf_strptr()\fR function.
33 A prototype for retrieving section names appears below. The file header
34 specifies the section name string table in the \fBe_shstrndx\fR member. The
35 following code loops through the sections, printing their names.
40 \fB/* handle the error */
41 if ((ehdr = elf32_getehdr(elf)) == 0) {
44 ndx = ehdr->e_shstrndx;
46 while ((scn = elf_nextscn(elf, scn)) != 0) {
48 if ((shdr = elf32_getshdr(scn)) != 0)
49 name = elf_strptr(elf, ndx, (size_t)shdr->sh_name);
50 printf("'%s'\en", name? name: "(null)");
58 See \fBattributes\fR(5) for descriptions of the following attributes:
66 ATTRIBUTE TYPE ATTRIBUTE VALUE
68 Interface Stability Stable
76 \fBelf\fR(3ELF), \fBelf32_getshdr\fR(3ELF), \fBelf32_xlatetof\fR(3ELF),
77 \fBelf_getdata\fR(3ELF), \fBlibelf\fR(3LIB), \fBattributes\fR(5)
81 A program may call \fBelf_getdata()\fR to retrieve an entire string table
82 section. For some applications, that would be both more efficient and more
83 convenient than using \fBelf_strptr()\fR.