MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


ELF Library Functions                            elfupdate(3ELF)



NAME
     elfupdate - update an ELF descriptor

SYNOPSIS
     cc [ flag ... ] file ... -lelf [ library ... ]
     #include 

     offt elfupdate(Elf *elf, ElfCmd cmd);


DESCRIPTION
     The elfupdate() function causes the library to examine  the
     information  associated  with an ELF descriptor, elf, and to
     recalculate the  structural  data  needed  to  generate  the
     file's image.


     The cmd argument can have the following values:

     ELFCNUL     This value tells elfupdate() to  recalculate
                    various   values,   updating   only  the  ELF
                    descriptor's memory structures. Any  modified
                    structures  are  flagged with the ELFDIRTY
                    bit. A program thus can update the structural
                    information  and  then reexamine them without
                    changing the file  associated  with  the  ELF
                    descriptor.  Because this does not change the
                    file, the ELF descriptor may  allow  reading,
                    writing,  or  both  reading  and writing (see
                    elfbegin(3ELF)).


     ELFCWRITE    If cmd has this  value,  elfupdate()  dupli-
                    cates  its ELFCNUL actions and also writes
                    any ``dirty'' information associated with the
                    ELF  descriptor  to the file. That is, when a
                    program has  used  elfgetdata(3ELF)  or  the
                    elfflagdata(3ELF)  facilities  to supply new
                    (or update existing) information for  an  ELF
                    descriptor,  those  data  will  be  examined,
                    coordinated,  translated  if  necessary  (see
                    elf32xlatetof(3ELF)),  and  written  to  the
                    file. When portions of the file are  written,
                    any  ELFDIRTY  bits  are reset, indicating
                    those items no longer need to be  written  to
                    the  file  (see elfflagdata(3ELF)). The sec-
                    tions' data are written in the order of their
                    section   header  entries,  and  the  section
                    header table is written to  the  end  of  the
                    file.  When  the  ELF  descriptor was created
                    with elfbegin(), it must have allowed  writ-
                    ing   the  file.  That  is,  the  elfbegin()



SunOS 5.11          Last change: 11 Jul 2001                    1






ELF Library Functions                            elfupdate(3ELF)



                    command must have been either  ELFCRDWR  or
                    ELFCWRITE.



     If elfupdate() succeeds, it returns the total size  of  the
     file  image  (not  the memory image), in bytes. Otherwise an
     error occurred, and the function returns -1.


     When updating the  internal  structures,  elfupdate()  sets
     some   members   itself.   Members   listed  below  are  the
     application's responsibility and retain the values given  by
     the program.


     The following table shows ELF Header members:



     Member             Notes

     eident[EIDATA]   Library controls other eident values
     etype
     emachine
     eversion
     eentry
     ephoff            Only when ELFLAYOUT asserted
     eshoff            Only when ELFLAYOUT asserted
     eflags
     eshstrndx



     The following table shows the Program Header members:



     Member             Notes

     ptype             The application controls all
     poffset           program header entries
     pvaddr
     ppaddr
     pfilesz
     pmemsz
     pflags
     palign







SunOS 5.11          Last change: 11 Jul 2001                    2






ELF Library Functions                            elfupdate(3ELF)



     The following table shows the Section Header members:



     Member             Notes

     shname
     shtype
     shflags
     shaddr
     shoffset          Only when ELFLAYOUT asserted
     shsize            Only when ELFLAYOUT asserted
     shlink
     shinfo
     shaddralign       Only when ELFLAYOUT asserted
     shentsize



     The following table shows the Data Descriptor members:



     Member             Notes

     dbuf
     dtype
     dsize
     doff              Only when ELFLAYOUT asserted
     dalign
     dversion



     Note that the program is responsible  for  two  particularly
     important  members  (among  others)  in  the ELF header. The
     eversion member controls the  version  of  data  structures
     written  to the file. If the version is EVNONE, the library
     uses its own internal version.  The  eident[EIDATA]  entry
     controls  the  data  encoding used in the file. As a special
     case, the value may be ELFDATANONE  to  request  the  native
     data  encoding for the host machine. An error occurs in this
     case if the native encoding doesn't match  a  file  encoding
     known by the library.


     Further  note  that  the  program  is  responsible  for  the
     shentsize  section header member. Although the library sets
     it for sections with known types, it  cannot  reliably  know
     the  correct  value  for  all  sections.  Consequently,  the
     library relies on the program  to  provide  the  values  for
     unknown  section  types. If the entry size is unknown or not



SunOS 5.11          Last change: 11 Jul 2001                    3






ELF Library Functions                            elfupdate(3ELF)



     applicable, the value should be set to 0.


     When deciding how to build  the  output  file,  elfupdate()
     obeys  the  alignments  of individual data buffers to create
     output sections. A  section's  most  strictly  aligned  data
     buffer  controls  the  section's alignment. The library also
     inserts padding between buffers, as necessary, to ensure the
     proper alignment of each buffer.

ATRIBUTES
     See attributes(5) for descriptions of the  following  attri-
     butes:



     
           ATRIBUTE TYPE               ATRIBUTE VALUE       
    
     Interface Stability          Stable                      
    
     MT-Level                     MT-Safe                     
    


SEE ALSO
     elf(3ELF),      elf32fsize(3ELF),      elf32getehdr(3ELF),
     elf32getshdr(3ELF),  elf32xlatetof(3ELF), elfbegin(3ELF),
     elfflagdata(3ELF), elfgetdata(3ELF), libelf(3LIB),  attri-
     butes(5)

NOTES
     As mentioned above, the ELFCWRITE command translates  data
     as necessary, before writing them to the file. This transla-
     tion is not always transparent to the  application  program.
     If a program has obtained pointers to data associated with a
     file   (for    example,    see    elf32getehdr(3ELF)    and
     elfgetdata(3ELF)),   the  program  should  reestablish  the
     pointers after calling elfupdate().
















SunOS 5.11          Last change: 11 Jul 2001                    4



OpenSolaris man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™