Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > E

elf_strptr(3E)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

elf_strptr — make a string pointer

SYNOPSIS

cc [flag... ] file... -lelf [library] ...

#include <libelf.h>

char *elf_strptr(Elf *elf, size_t section, size_t offset);

DESCRIPTION

This function converts a string section offset to a string pointer. elf identifies the file in which the string section resides, and section gives the section table index for the strings. elf_strptr normally returns a pointer to a string, but it returns a null pointer when elf is null, section is invalid or is not a section of type SHT_STRTAB, the section data cannot be obtained, offset is invalid, or an error occurs.

EXAMPLES

A prototype for retrieving section names appears below. The file header specifies the section name string table in the e_shstrndx member. The following code loops through the sections, printing their names.

if ((ehdr = elf32_getehdr(elf)) == 0) { /* handle the error */ return; } ndx = ehdr->e_shstrndx; scn = 0; while ((scn = elf_nextscn(elf, scn)) != 0) { char *name = 0; if ((shdr = elf32_getshdr(scn)) != 0) name = elf_strptr(elf, ndx, (size_t)shdr->sh_name); printf("'%s'\n", name? name: "(null)"); }

Note

A program may call elf_getdata to retrieve an entire string table section. For some applications, that would be both more efficient and more convenient than using elf_strptr.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.