home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / libelf / elf_getdata.z / elf_getdata
Encoding:
Text File  |  1998-10-30  |  23.2 KB  |  289 lines

  1.  
  2.  
  3.  
  4. EEEELLLLFFFF____GGGGEEEETTTTDDDDAAAATTTTAAAA((((3333EEEE))))                                                EEEELLLLFFFF____GGGGEEEETTTTDDDDAAAATTTTAAAA((((3333EEEE))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      _eeee_llll_ffff______gggg_eeee_tttt_dddd_aaaa_tttt_aaaa, _eeee_llll_ffff______nnnn_eeee_wwww_dddd_aaaa_tttt_aaaa, _eeee_llll_ffff______rrrr_aaaa_wwww_dddd_aaaa_tttt_aaaa - get section data
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      _cccc_cccc [_f_l_a_g ...] _f_i_l_e ...  _----_llll_eeee_llll_ffff [_l_i_b_r_a_r_y ...]
  13.  
  14.      _####_iiii_nnnn_cccc_llll_uuuu_dddd_eeee _<<<<_llll_iiii_bbbb_eeee_llll_ffff_...._hhhh_>>>>
  15.      _EEEE_llll_ffff______DDDD_aaaa_tttt_aaaa _****_eeee_llll_ffff______gggg_eeee_tttt_dddd_aaaa_tttt_aaaa_((((_EEEE_llll_ffff______SSSS_cccc_nnnn _****_ssss_cccc_nnnn_,,,, _EEEE_llll_ffff______DDDD_aaaa_tttt_aaaa _****_dddd_aaaa_tttt_aaaa_))))_;;;;
  16.      _EEEE_llll_ffff______DDDD_aaaa_tttt_aaaa _****_eeee_llll_ffff______nnnn_eeee_wwww_dddd_aaaa_tttt_aaaa_((((_EEEE_llll_ffff______SSSS_cccc_nnnn _****_ssss_cccc_nnnn_))))_;;;;
  17.      _EEEE_llll_ffff______DDDD_aaaa_tttt_aaaa _****_eeee_llll_ffff______rrrr_aaaa_wwww_dddd_aaaa_tttt_aaaa_((((_EEEE_llll_ffff______SSSS_cccc_nnnn _****_ssss_cccc_nnnn_,,,, _EEEE_llll_ffff______DDDD_aaaa_tttt_aaaa _****_dddd_aaaa_tttt_aaaa_))))_;;;;
  18.  
  19. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  20.      These functions access and manipulate the data associated with a section
  21.      descriptor, _s_c_n.  When reading an existing file, a section will have a
  22.      single data buffer associated with it.  A program may build a new section
  23.      in pieces, however, composing the new data from multiple data buffers.
  24.      For this reason, ``the'' data for a section should be viewed as a list of
  25.      buffers, each of which is available through a data descriptor.
  26.  
  27.      _eeee_llll_ffff______gggg_eeee_tttt_dddd_aaaa_tttt_aaaa lets a program step through a section's data list.  If the
  28.      incoming data descriptor, _d_a_t_a, is null, the function returns the first
  29.      buffer associated with the section.  Otherwise, _d_a_t_a should be a data
  30.      descriptor associated with _s_c_n, and the function gives the program access
  31.      to the next data element for the section.  If _s_c_n is null or an error
  32.      occurs, _eeee_llll_ffff______gggg_eeee_tttt_dddd_aaaa_tttt_aaaa returns a null pointer.
  33.  
  34.      _eeee_llll_ffff______gggg_eeee_tttt_dddd_aaaa_tttt_aaaa translates the data from file representations into memory
  35.      representations [see _eeee_llll_ffff______xxxx_llll_aaaa_tttt_eeee(3E)] and presents objects with memory data
  36.      types to the program, based on the file's _c_l_a_s_s [see _eeee_llll_ffff(3E)].  The
  37.      working library version [see _eeee_llll_ffff______vvvv_eeee_rrrr_ssss_iiii_oooo_nnnn(3E)] specifies what version of
  38.      the memory structures the program wishes _eeee_llll_ffff______gggg_eeee_tttt_dddd_aaaa_tttt_aaaa to present.
  39.  
  40.      _eeee_llll_ffff______nnnn_eeee_wwww_dddd_aaaa_tttt_aaaa creates a new data descriptor for a section, appending it to
  41.      any data elements already associated with the section.  As described
  42.      below, the new data descriptor appears empty, indicating the element
  43.      holds no data.  For convenience, the descriptor's type (_dddd______tttt_yyyy_pppp_eeee below) is
  44.      set to _EEEE_LLLL_FFFF______TTTT______BBBB_YYYY_TTTT_EEEE, and the version (_dddd______vvvv_eeee_rrrr_ssss_iiii_oooo_nnnn below) is set to the
  45.      working version.  The program is responsible for setting (or changing)
  46.      the descriptor members as needed.  This function implicitly sets the
  47.      _EEEE_LLLL_FFFF______FFFF______DDDD_IIII_RRRR_TTTT_YYYY bit for the section's data [see _eeee_llll_ffff______ffff_llll_aaaa_gggg(3E)].  If _s_c_n is
  48.      null or an error occurs, _eeee_llll_ffff______nnnn_eeee_wwww_dddd_aaaa_tttt_aaaa returns a null pointer.
  49.  
  50.      _eeee_llll_ffff______rrrr_aaaa_wwww_dddd_aaaa_tttt_aaaa differs from _eeee_llll_ffff______gggg_eeee_tttt_dddd_aaaa_tttt_aaaa by returning only uninterpreted
  51.      bytes, regardless of the section type.  This function typically should be
  52.      used only to retrieve a section image from a file being read, and then
  53.      only when a program must avoid the automatic data translation described
  54.      below.  Moreover, a program may not close or disable [see _eeee_llll_ffff______cccc_nnnn_tttt_llll(3E)]
  55.      the file descriptor associated with _e_l_f before the initial raw operation,
  56.      because _eeee_llll_ffff______rrrr_aaaa_wwww_dddd_aaaa_tttt_aaaa might read the data from the file to ensure it
  57.      doesn't interfere with _eeee_llll_ffff______gggg_eeee_tttt_dddd_aaaa_tttt_aaaa.  See _eeee_llll_ffff______rrrr_aaaa_wwww_ffff_iiii_llll_eeee(3E) for a related
  58.      facility that applies to the entire file.  When _eeee_llll_ffff______gggg_eeee_tttt_dddd_aaaa_tttt_aaaa provides the
  59.  
  60.  
  61.                                                                         PPPPaaaaggggeeee 1111
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68. EEEELLLLFFFF____GGGGEEEETTTTDDDDAAAATTTTAAAA((((3333EEEE))))                                                EEEELLLLFFFF____GGGGEEEETTTTDDDDAAAATTTTAAAA((((3333EEEE))))
  69.  
  70.  
  71.  
  72.      right translation, its use is recommended over _eeee_llll_ffff______rrrr_aaaa_wwww_dddd_aaaa_tttt_aaaa.  If _s_c_n is
  73.      null or an error occurs, _eeee_llll_ffff______rrrr_aaaa_wwww_dddd_aaaa_tttt_aaaa returns a null pointer.
  74.  
  75.      The _EEEE_llll_ffff______DDDD_aaaa_tttt_aaaa structure includes the following members.
  76.  
  77.                   _vvvv_oooo_iiii_dddd            _****_dddd______bbbb_uuuu_ffff_;;;;
  78.                   _EEEE_llll_ffff______TTTT_yyyy_pppp_eeee        _dddd______tttt_yyyy_pppp_eeee_;;;;
  79.                   _ssss_iiii_zzzz_eeee______tttt          _dddd______ssss_iiii_zzzz_eeee_;;;;
  80.                   _oooo_ffff_ffff______tttt           _dddd______oooo_ffff_ffff_;;;;
  81.                   _ssss_iiii_zzzz_eeee______tttt          _dddd______aaaa_llll_iiii_gggg_nnnn_;;;;
  82.                   _uuuu_nnnn_ssss_iiii_gggg_nnnn_eeee_dddd        _dddd______vvvv_eeee_rrrr_ssss_iiii_oooo_nnnn_;;;;
  83.  
  84.      These members are available for direct manipulation by the program.
  85.      Descriptions appear below.
  86.  
  87.      _dddd______bbbb_uuuu_ffff         A pointer to the data buffer resides here.  A data element
  88.                    with no data has a null pointer.
  89.  
  90.      _dddd______tttt_yyyy_pppp_eeee        This member's value specifies the type of the data to which
  91.                    _dddd______bbbb_uuuu_ffff points.  A section's type determines how to interpret
  92.                    the section contents, as summarized below.
  93.  
  94.      _dddd______ssss_iiii_zzzz_eeee        This member holds the total size, in bytes, of the memory
  95.                    occupied by the data.  This may differ from the size as
  96.                    represented in the file.  The size will be zero if no data
  97.                    exist.  [See the discussion of _SSSS_HHHH_TTTT______NNNN_OOOO_BBBB_IIII_TTTT_SSSS below for more
  98.                    information.]
  99.  
  100.      _dddd______oooo_ffff_ffff         This member gives the offset, within the section, at which
  101.                    the buffer resides.  This offset is relative to the file's
  102.                    section, not the memory object's.
  103.  
  104.      _dddd______aaaa_llll_iiii_gggg_nnnn       This member holds the buffer's required alignment, from the
  105.                    beginning of the section.  That is, _dddd______oooo_ffff_ffff will be a
  106.                    multiple of this member's value.  For example, if this
  107.                    member's value is four, the beginning of the buffer will be
  108.                    four-byte aligned within the section.  Moreover, the entire
  109.                    section will be aligned to the maximum of its constituents,
  110.                    thus ensuring appropriate alignment for a buffer within the
  111.                    section and within the file.
  112.  
  113.      _dddd______vvvv_eeee_rrrr_ssss_iiii_oooo_nnnn     This member holds the version number of the objects in the
  114.                    buffer.  When the library originally read the data from the
  115.                    object file, it used the working version to control the
  116.                    translation to memory objects.
  117.  
  118. DDDDAAAATTTTAAAA AAAALLLLIIIIGGGGNNNNMMMMEEEENNNNTTTT
  119.      As mentioned above, data buffers within a section have explicit alignment
  120.      constraints.  Consequently, adjacent buffers sometimes will not abut,
  121.      causing ``holes'' within a section.  Programs that create output files
  122.      have two ways of dealing with these holes.
  123.  
  124.  
  125.  
  126.  
  127.                                                                         PPPPaaaaggggeeee 2222
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134. EEEELLLLFFFF____GGGGEEEETTTTDDDDAAAATTTTAAAA((((3333EEEE))))                                                EEEELLLLFFFF____GGGGEEEETTTTDDDDAAAATTTTAAAA((((3333EEEE))))
  135.  
  136.  
  137.  
  138.      First, the program can use _eeee_llll_ffff______ffff_iiii_llll_llll to tell the library how to set the
  139.      intervening bytes.  When the library must generate gaps in the file, it
  140.      uses the fill byte to initialize the data there.  The library's initial
  141.      fill value is zero, and _eeee_llll_ffff______ffff_iiii_llll_llll lets the application change that.
  142.  
  143.      Second, the application can generate its own data buffers to occupy the
  144.      gaps, filling the gaps with values appropriate for the section being
  145.      created.  A program might even use different fill values for different
  146.      sections.  For example, it could set text sections' bytes to no-operation
  147.      instructions, while filling data section holes with zero.  Using this
  148.      technique, the library finds no holes to fill, because the application
  149.      eliminated them.
  150.  
  151. SSSSEEEECCCCTTTTIIIIOOOONNNN AAAANNNNDDDD MMMMEEEEMMMMOOOORRRRYYYY TTTTYYYYPPPPEEEESSSS
  152.      _eeee_llll_ffff______gggg_eeee_tttt_dddd_aaaa_tttt_aaaa interprets sections' data according to the section type, as
  153.      noted in the section header available through _eeee_llll_ffff______gggg_eeee_tttt_ssss_hhhh_dddd_rrrr.  The following
  154.      table shows the section types and how the library represents them with
  155.      memory data types for the 32-bit file class.  Other classes would have
  156.      similar tables.  By implication, the memory data types control
  157.      translation by _eeee_llll_ffff______xxxx_llll_aaaa_tttt_eeee.
  158.  
  159.                      Section Type    _EEEE_llll_ffff______TTTT_yyyy_pppp_eeee     32-Bit Type
  160.                      _________________________________________
  161.                      _SSSS_HHHH_TTTT______DDDD_YYYY_NNNN_AAAA_MMMM_IIII_CCCC    _EEEE_LLLL_FFFF______TTTT______DDDD_YYYY_NNNN    _EEEE_llll_ffff_3333_2222______DDDD_yyyy_nnnn
  162.                      _SSSS_HHHH_TTTT______DDDD_YYYY_NNNN_SSSS_YYYY_MMMM     _EEEE_LLLL_FFFF______TTTT______SSSS_YYYY_MMMM    _EEEE_llll_ffff_3333_2222______SSSS_yyyy_mmmm
  163.                      _SSSS_HHHH_TTTT______HHHH_AAAA_SSSS_HHHH       _EEEE_LLLL_FFFF______TTTT______WWWW_OOOO_RRRR_DDDD   _EEEE_llll_ffff_3333_2222______WWWW_oooo_rrrr_dddd
  164.                      _SSSS_HHHH_TTTT______NNNN_OOOO_BBBB_IIII_TTTT_SSSS     _EEEE_LLLL_FFFF______TTTT______BBBB_YYYY_TTTT_EEEE   _uuuu_nnnn_ssss_iiii_gggg_nnnn_eeee_dddd _cccc_hhhh_aaaa_rrrr
  165.                      _SSSS_HHHH_TTTT______NNNN_OOOO_TTTT_EEEE       _EEEE_LLLL_FFFF______TTTT______BBBB_YYYY_TTTT_EEEE   _uuuu_nnnn_ssss_iiii_gggg_nnnn_eeee_dddd _cccc_hhhh_aaaa_rrrr
  166.                      _SSSS_HHHH_TTTT______NNNN_UUUU_LLLL_LLLL       _n_o_n_e         _n_o_n_e
  167.                      _SSSS_HHHH_TTTT______PPPP_RRRR_OOOO_GGGG_BBBB_IIII_TTTT_SSSS   _EEEE_LLLL_FFFF______TTTT______BBBB_YYYY_TTTT_EEEE   _uuuu_nnnn_ssss_iiii_gggg_nnnn_eeee_dddd _cccc_hhhh_aaaa_rrrr
  168.                      _SSSS_HHHH_TTTT______RRRR_EEEE_LLLL        _EEEE_LLLL_FFFF______TTTT______RRRR_EEEE_LLLL    _EEEE_llll_ffff_3333_2222______RRRR_eeee_llll
  169.                      _SSSS_HHHH_TTTT______RRRR_EEEE_LLLL_AAAA       _EEEE_LLLL_FFFF______TTTT______RRRR_EEEE_LLLL_AAAA   _EEEE_llll_ffff_3333_2222______RRRR_eeee_llll_aaaa
  170.                      _SSSS_HHHH_TTTT______SSSS_TTTT_RRRR_TTTT_AAAA_BBBB     _EEEE_LLLL_FFFF______TTTT______BBBB_YYYY_TTTT_EEEE   _uuuu_nnnn_ssss_iiii_gggg_nnnn_eeee_dddd _cccc_hhhh_aaaa_rrrr
  171.                      _SSSS_HHHH_TTTT______SSSS_YYYY_MMMM_TTTT_AAAA_BBBB     _EEEE_LLLL_FFFF______TTTT______SSSS_YYYY_MMMM    _EEEE_llll_ffff_3333_2222______SSSS_yyyy_mmmm
  172.                      _o_t_h_e_r          _EEEE_LLLL_FFFF______TTTT______BBBB_YYYY_TTTT_EEEE   _uuuu_nnnn_ssss_iiii_gggg_nnnn_eeee_dddd _cccc_hhhh_aaaa_rrrr
  173.                      _________________________________________
  174.                                   ||||||||||||||
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.                                                ||||||||||||||
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      _eeee_llll_ffff______rrrr_aaaa_wwww_dddd_aaaa_tttt_aaaa creates a buffer with type _EEEE_LLLL_FFFF______TTTT______BBBB_YYYY_TTTT_EEEE.
  203.  
  204.      As mentioned above, the program's working version controls what
  205.      structures the library creates for the application.  The library
  206.      similarly interprets section types according to the versions.  If a
  207.      section type ``belongs'' to a version newer than the application's
  208.      working version, the library does not translate the section data.
  209.      Because the application cannot know the data format in this case, the
  210.      library presents an untranslated buffer of type _EEEE_LLLL_FFFF______TTTT______BBBB_YYYY_TTTT_EEEE, just as it
  211.      would for an unrecognized section type.
  212.  
  213.      A section with a special type, _SSSS_HHHH_TTTT______NNNN_OOOO_BBBB_IIII_TTTT_SSSS, occupies no space in an object
  214.      file, even when the section header indicates a non-zero size.
  215.      _eeee_llll_ffff______gggg_eeee_tttt_dddd_aaaa_tttt_aaaa and _eeee_llll_ffff______rrrr_aaaa_wwww_dddd_aaaa_tttt_aaaa ``work'' on such a section, setting the _d_a_t_a
  216.  
  217.  
  218.  
  219.                                                                         PPPPaaaaggggeeee 3333
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226. EEEELLLLFFFF____GGGGEEEETTTTDDDDAAAATTTTAAAA((((3333EEEE))))                                                EEEELLLLFFFF____GGGGEEEETTTTDDDDAAAATTTTAAAA((((3333EEEE))))
  227.  
  228.  
  229.  
  230.      structure to have a null buffer pointer and the type indicated above.
  231.      Although no data are present, the _dddd______ssss_iiii_zzzz_eeee value is set to the size from
  232.      the section header.  When a program is creating a new section of type
  233.      _SSSS_HHHH_TTTT______NNNN_OOOO_BBBB_IIII_TTTT_SSSS, it should use _eeee_llll_ffff______nnnn_eeee_wwww_dddd_aaaa_tttt_aaaa to add data buffers to the section.
  234.      These ``empty'' data buffers should have the _dddd______ssss_iiii_zzzz_eeee members set to the
  235.      desired size and the _dddd______bbbb_uuuu_ffff members set to null.
  236.  
  237. EEEEXXXXAAAAMMMMPPPPLLLLEEEE
  238.      The following fragment obtains the string table that holds section names
  239.      (ignoring error checking).  See _eeee_llll_ffff______ssss_tttt_rrrr_pppp_tttt_rrrr(3E) for a variation of string
  240.      table handling.
  241.  
  242.           _eeee_hhhh_dddd_rrrr _==== _eeee_llll_ffff_3333_2222______gggg_eeee_tttt_eeee_hhhh_dddd_rrrr_((((_eeee_llll_ffff_))))_;;;;
  243.           _ssss_cccc_nnnn _==== _eeee_llll_ffff______gggg_eeee_tttt_ssss_cccc_nnnn_((((_eeee_llll_ffff_,,,, _((((_ssss_iiii_zzzz_eeee______tttt_))))_eeee_hhhh_dddd_rrrr_----_>>>>_eeee______ssss_hhhh_ssss_tttt_rrrr_nnnn_dddd_xxxx_))))_;;;;
  244.           _ssss_hhhh_dddd_rrrr _==== _eeee_llll_ffff_3333_2222______gggg_eeee_tttt_ssss_hhhh_dddd_rrrr_((((_ssss_cccc_nnnn_))))_;;;;
  245.           _iiii_ffff _((((_ssss_hhhh_dddd_rrrr_----_>>>>_ssss_hhhh______tttt_yyyy_pppp_eeee _!!!!_==== _SSSS_HHHH_TTTT______SSSS_TTTT_RRRR_TTTT_AAAA_BBBB_))))
  246.           _{{{{
  247.                   _////_**** _nnnn_oooo_tttt _aaaa _ssss_tttt_rrrr_iiii_nnnn_gggg _tttt_aaaa_bbbb_llll_eeee _****_////
  248.           _}}}}
  249.           _dddd_aaaa_tttt_aaaa _==== _0000_;;;;
  250.           _iiii_ffff _((((_((((_dddd_aaaa_tttt_aaaa _==== _eeee_llll_ffff______gggg_eeee_tttt_dddd_aaaa_tttt_aaaa_((((_ssss_cccc_nnnn_,,,, _dddd_aaaa_tttt_aaaa_))))_)))) _====_==== _0000 _||||_|||| _dddd_aaaa_tttt_aaaa_----_>>>>_dddd______ssss_iiii_zzzz_eeee _====_==== _0000_))))
  251.           _{{{{
  252.                   _////_**** _eeee_rrrr_rrrr_oooo_rrrr _oooo_rrrr _nnnn_oooo _dddd_aaaa_tttt_aaaa _****_////
  253.           _}}}}
  254.  
  255.      The _eeee______ssss_hhhh_ssss_tttt_rrrr_nnnn_dddd_xxxx member in an ELF header holds the section table index of
  256.      the string table.  The program gets a section descriptor for that
  257.      section, verifies it is a string table, and then retrieves the data.
  258.      When this fragment finishes, _dddd_aaaa_tttt_aaaa_----_>>>>_dddd______bbbb_uuuu_ffff points at the first byte of the
  259.      string table, and _dddd_aaaa_tttt_aaaa_----_>>>>_dddd______ssss_iiii_zzzz_eeee holds the string table's size in bytes.
  260.  
  261. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  262.      _eeee_llll_ffff(3E), _eeee_llll_ffff______cccc_nnnn_tttt_llll(3E), _eeee_llll_ffff______ffff_iiii_llll_llll(3E), _eeee_llll_ffff______ffff_llll_aaaa_gggg(3E), _eeee_llll_ffff______gggg_eeee_tttt_eeee_hhhh_dddd_rrrr(3E),
  263.      _eeee_llll_ffff______gggg_eeee_tttt_ssss_cccc_nnnn(3E), _eeee_llll_ffff______gggg_eeee_tttt_ssss_hhhh_dddd_rrrr(3E), _eeee_llll_ffff______rrrr_aaaa_wwww_ffff_iiii_llll_eeee(3E), _eeee_llll_ffff______vvvv_eeee_rrrr_ssss_iiii_oooo_nnnn(3E),
  264.      _eeee_llll_ffff______xxxx_llll_aaaa_tttt_eeee(3E).
  265.  
  266. NNNNOOOOTTTTEEEESSSS
  267.      The 64-bit class functions work identically, simply replacing all
  268.      instances of 32 in the descriptions with 64.
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.                                                                         PPPPaaaaggggeeee 4444
  286.  
  287.  
  288.  
  289.