source: rtems/cpukit/libdl/rtl-elf.h @ 3feb372

4.115
Last change on this file since 3feb372 was ae5fe7e6, checked in by Chris Johns <chrisj@…>, on 10/27/14 at 01:09:41

cpukit: Add libdl with the Runtime Loader (RTL) code.

This is a merge of the RTL project.

  • Property mode set to 100644
File size: 5.1 KB
Line 
1/*
2 *  COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org>
3 *
4 *  The license and distribution terms for this file may be
5 *  found in the file LICENSE in this distribution or at
6 *  http://www.rtems.com/license/LICENSE.
7 */
8/**
9 * @file
10 *
11 * @ingroup rtems_rtl
12 *
13 * @brief RTEMS Run-Time Linker ELF Headers
14 */
15
16#if !defined (_RTEMS_RTL_ELF_H_)
17#define _RTEMS_RTL_ELF_H_
18
19#include "rtl-fwd.h"
20#include "rtl-obj-fwd.h"
21#include "rtl-sym.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif /* __cplusplus */
26
27/**
28 ** Imported NetBSD ELF Specifics Start.
29 **/
30
31/*
32 * Always 32bit for RTEMS at the moment. Do not add '()'. Leave plain.
33 */
34#define ELFSIZE 32
35
36/*
37 * Define _STANDALONE then remove after.
38 */
39#define _STANDALONE 1
40
41#include <sys/cdefs.h>
42#include <sys/exec_elf.h>
43
44#undef _STANDALONE
45
46/**
47 ** Imported NetBSD ELF Specifics End.
48 **/
49
50/**
51 * Maximum string length. This a read buffering limit rather than a
52 * specific ELF length. I hope this is ok as I am concerned about
53 * some C++ symbol lengths.
54 */
55#define RTEMS_RTL_ELF_STRING_MAX (256)
56
57/**
58 * Architecture specific handler to check is a relocation record's type is
59 * required to resolve a symbol.
60 *
61 * @param type The type field in the relocation record.
62 * @retval true The relocation record require symbol resolution.
63 * @retval false The relocation record does not require symbol resolution.
64 */
65bool rtems_rtl_elf_rel_resolve_sym (Elf_Word type);
66
67/**
68 * Architecture specific relocation handler compiled in for a specific
69 * architecture by the build system. The handler applies the relocation
70 * to the target.
71 *
72 * @param obj The object file being relocated.
73 * @param rel The ELF relocation record.
74 * @param sect The section of the object file the relocation is for.
75 * @param symname The symbol's name.
76 * @param syminfo The ELF symbol info field.
77 * @param symvalue If a symbol is referenced, this is the symbols value.
78 * @retval bool The relocation has been applied.
79 * @retval bool The relocation could not be applied.
80 */
81bool rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t*      obj,
82                                 const Elf_Rel*              rel,
83                                 const rtems_rtl_obj_sect_t* sect,
84                                 const char*                 symname,
85                                 const Elf_Byte              syminfo,
86                                 const Elf_Word              symvalue);
87
88/**
89 * Architecture specific relocation handler compiled in for a specific
90 * architecture by the build system. The handler applies the relocation
91 * to the target.
92 *
93 * @param obj The object file being relocated.
94 * @param rela The ELF addend relocation record.
95 * @param sect The section of the object file the relocation is for.
96 * @param symname The symbol's name.
97 * @param syminfo The ELF symbol info field.
98 * @param symvalue If a symbol is referenced, this is the symbols value.
99 * @retval bool The relocation has been applied.
100 * @retval bool The relocation could not be applied.
101 */
102bool rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t*      obj,
103                                  const Elf_Rela*             rela,
104                                  const rtems_rtl_obj_sect_t* sect,
105                                  const char*                 symname,
106                                  const Elf_Byte              syminfo,
107                                  const Elf_Word              symvalue);
108
109/**
110 * Find the symbol. The symbol is passed as an ELF type symbol with the name
111 * and the value returned is the absolute address of the symbol.
112 *
113 * If the symbol type is STT_NOTYPE the symbol references a global symbol. The
114 * gobal symbol table is searched to find it and that value returned. If the
115 * symbol is local to the object module the section for the symbol is located
116 * and it's base added to the symbol's value giving an absolute location.
117 *
118 * @param obj The object the symbol is being resolved for.
119 * @param sym The ELF type symbol.
120 * @param symname The sym's name read from the symbol string table.
121 * @param value Return the value of the symbol. Only valid if the return value
122 *              is true.
123 * @retval true The symbol resolved.
124 * @retval false The symbol could not be result. The RTL error is set.
125 */
126bool rtems_rtl_elf_find_symbol (rtems_rtl_obj_t* obj,
127                                const Elf_Sym*   sym,
128                                const char*      symname,
129                                Elf_Word*        value);
130
131/**
132 * The ELF format check handler.
133 *
134 * @param obj The object being checked.
135 * @param fd The file descriptor.
136 */
137bool rtems_rtl_elf_file_check (rtems_rtl_obj_t* obj, int fd);
138
139/**
140 * The ELF file details handler.
141 *
142 * @param obj Load the details of the obj.
143 */
144bool rtems_rtl_elf_load_details (rtems_rtl_obj_t* obj);
145
146/**
147 * The ELF format load handler.
148 *
149 * @param obj The object to load.
150 * @param fd The file descriptor.
151 */
152bool rtems_rtl_elf_file_load (rtems_rtl_obj_t* obj, int fd);
153
154/**
155 * The ELF format signature handler.
156 *
157 * @return rtems_rtl_loader_format_t* The format's signature.
158 */
159rtems_rtl_loader_format_t* rtems_rtl_elf_file_sig (void);
160
161#ifdef __cplusplus
162}
163#endif /* __cplusplus */
164
165#endif
Note: See TracBrowser for help on using the repository browser.