Sun Microsystems, Inc.
spacerspacer
spacer   www.sun.com docs.sun.com | | |  
spacer
black dot
   
A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y   Z
    
 
ELF Library Functionself_getident(3ELF)


NAME

 elf_getident - retrieve file identification data

SYNOPSIS

 
cc [ flag ... ] file ... -lelf [ library ... ]
#include <libelf.h>
char *elf_getident(Elf *elf, size_t *ptr);

DESCRIPTION

 

As elf(3ELF) explains, ELF provides a framework for various classes of files, where basic objects may have 32 bits, 64 bits, etc. To accommodate these differences, without forcing the larger sizes on smaller machines, the initial bytes in an ELF file hold identification information common to all file classes. Every ELF header's e_ident has EI_NIDENT bytes with the following interpretation:

e_ident IndexValuePurpose
   
EI_MAG0ELFMAG0File identification
EI_MAG1ELFMAG1 
EI_MAG2ELFMAG2 
EI_MAG3ELFMAG3 
   
EI_CLASSELFCLASSNONEFile class
 ELFCLASS32 
 ELFCLASS64 
   
EI_DATAELFDATANONEData encoding
 ELFDATA2LSB 
 ELFDATA2MSB 
   
EI_VERSIONEV_CURRENTFile version
   
7-150 Unused, set to zero

Other kinds of files (see elf_kind(3ELF)) also may have identification data, though they would not conform to e_ident.

elf_getident() returns a pointer to the file's ``initial bytes.'' If the library recognizes the file, a conversion from the file image to the memory image may occur. In any case, the identification bytes are guaranteed not to have been modified, though the size of the unmodified area depends on the file type. If ptr is non-null, the library stores the number of identification bytes in the location to which ptr points. If no data are present, elf is null, or an error occurs, the return value is a null pointer, with 0 stored through ptr, if ptr is non-null.

ATTRIBUTES

 

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPEATTRIBUTE VALUE
Interface StabilityStable
MT-LevelMT-Safe

SEE ALSO

 

elf(3ELF), elf32_getehdr(3ELF), elf_begin(3ELF), elf_kind(3ELF), elf_rawfile(3ELF), libelf(3LIB), attributes(5)


SunOS 5.9Go To TopLast Changed 11 Jul 2001

 
      
      
Copyright 2002 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.