source: rtems-tools/linkers/rld-elf.h @ ec24a37

4.104.11
Last change on this file since ec24a37 was ec24a37, checked in by Chris Johns <chrisj@…>, on May 6, 2012 at 10:47:11 PM

Add to git.

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 * Copyright (c) 2011, Chris Johns <chrisj@rtems.org>
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16/**
17 * @file
18 *
19 * @ingroup rtems-ld
20 *
21 * @brief RTEMS Linker ELF module manages the libelf interface.
22 *
23 */
24
25#if !defined (_RLD_ELF_H_)
26#define _RLD_ELF_H_
27
28#include <list>
29
30#include <rld.h>
31
32namespace rld
33{
34  namespace elf
35  {
36    /**
37     * Sections.
38     */
39    struct section
40    {
41      int         index; //< The section header index.
42      std::string name;  //< The section's name.
43      elf_scn*    scn;   //< ELF private section data.
44      elf_shdr    shdr;  //< The section header.
45      elf_data*   data;  //< The section's data.
46     
47      /**
48       * Construct the section and get the data value.
49       */
50      section (int          index,
51               std::string& name,
52               elf_scn*     scn,
53               elf_shdr&    sdhr);
54
55      /**
56       * Default constructor.
57       */
58      section ();
59    };
60
61    /**
62     * Container of section headers.
63     */
64    typedef std::list < section > sections;
65
66    /**
67     * Get the machine type detected in the object files as their headers are read.
68     */
69    const std::string machine_type ();
70
71    /**
72     * Begin a libelf session with the image.
73     */
74    void begin (rld::files::image& image);
75
76    /**
77     * End the libelf session with the image.
78     */
79    void end (rld::files::image& image);
80
81    /**
82     * Get the ELF header.
83     */
84    void get_header (rld::files::image& image, elf_ehdr& ehdr);
85
86    /**
87     * Get the section headers for an object file.
88     */
89    void get_section_headers (rld::files::object& object, 
90                              sections&           secs,
91                              unsigned int        type = SHT_NULL);
92 
93    /**
94     * Load the symbol table with the symbols.
95     */
96    void load_symbol_table (rld::symbols::table& exported,
97                            rld::files::object&  object, 
98                            section&             sec,
99                            bool                 local = false,
100                            bool                 weak = true,
101                            bool                 global = true);
102   
103    /**
104     * Load the symbol table with an object's symbols.
105     */
106    void load_symbols (rld::symbols::table& symbols,
107                       rld::files::object&  object, 
108                       bool                 local = false,
109                       bool                 weak = true,
110                       bool                 global = true);
111
112    /**
113     * Get a string.
114     */
115    std::string get_string (rld::files::object& object, 
116                            int                 section,
117                            size_t              offset);
118  }
119}
120
121#endif
Note: See TracBrowser for help on using the repository browser.