*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->IRIX man pages -> libelf/elf_strptr (3)              
Title
Content
Arch
Section
 

Contents


ELF_STRPTR(3E)							ELF_STRPTR(3E)


NAME    [Toc]    [Back]

     elf_strptr	- make a string	pointer

SYNOPSIS    [Toc]    [Back]

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

     #include <libelf.h>

     char *elf_strptr(Elf *elf,	size_t section,	size_t offset);
     #define _LIBELF_XTND_64
     char *elf_strptr(Elf *elf,	Elf64_Xword section, Elf64_Xword size_t	offset);

DESCRIPTION    [Toc]    [Back]

     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.

EXAMPLE    [Toc]    [Back]

     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)");
	  }

SEE ALSO    [Toc]    [Back]

      
      
     elf(3E), elf_getdata(3E), elf_getshdr(3E),	elf_xlate(3E).

NOTE    [Toc]    [Back]

     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.

     The use of	a size_t in a 32-bit compile with elf_strptr is	unfortunate,
     since that	makes it impossible to deal with certain object	files.	If,
     when the 32-bit app is compiled, _LIBELF_XTND_64 is defined, then the
     function interface	changes	to have	64-bit fields.	If _LIBELF_XTND_64 is



									Page 1






ELF_STRPTR(3E)							ELF_STRPTR(3E)



     defined at	compile-time, then instead of linking with -lelf, link with
     -lelf_xtnd.  There	is a corresponding -ldwarf_xtnd.  It is	essential that
     a 32-bit application compiled with	_LIBELF_XTND_64	be *entirely* compiled
     with _LIBELF_XTND_64 defined.

     Applications which	are built as 64-bit applications can ignore
     _LIBELF_XTND_64: it has no	effect on them and 64-bit applications always
     link with -lelf never with	-lelf_xtnd.


									PPPPaaaaggggeeee 2222
[ Back ]
 Similar pages
Name OS Title
stpcpy Linux copy a string returning a pointer to its end
stpncpy Linux copy a fixed-size string, returning a pointer to its end
wcpcpy Linux copy a wide character string, returning a pointer to its end
wcpncpy Linux copy a fixed-size string of wide characters, returning a pointer to its end
csfgss_pPtr Tru64 get a pointer to an OID or an OID set
glcgetpointer IRIX return pointer value
gluNurbsCallbackDataEXT Tru64 set a user data pointer
glGetPointerv Tru64 return the address of the specified pointer
glgetpointerv IRIX return the address of the specified pointer
getsvc Tru64 Get a pointer to the svcinfo structure.
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service