source: rtems/cpukit/libdl/rtl-elf.h @ 6c9f017

5
Last change on this file since 6c9f017 was 6c9f017, checked in by Chris Johns <chrisj@…>, on 02/02/19 at 04:09:53

libdl: Add powerpc large memory and small data support.

  • Add support for architecure sections that can be handled by the architecture back end.
  • Add trampoline/fixup support for PowerPC. This means the PowerPC now supports large memory loading of applications.
  • Add a bit allocator to manage small block based regions of memory.
  • Add small data (sdata/sbss) support for the PowerPC. The support makes the linker allocated small data region of memory a global resource available to libdl loaded object files.

Updates #3687
Updates #3685

  • Property mode set to 100644
File size: 8.6 KB
Line 
1/*
2 *  COPYRIGHT (c) 2012-2018 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.org/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 <rtems/rtl/rtl-fwd.h>
20#include <rtems/rtl/rtl-obj-fwd.h>
21#include <rtems/rtl/rtl-sym.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif /* __cplusplus */
26
27/**
28 ** Imported NetBSD ELF Specifics Start.
29 **/
30
31/*
32 * Do not add '()'. Leave plain.
33 */
34#if defined(__powerpc64__) || defined(__arch64__)
35#define ELFSIZE 64
36#else
37#define ELFSIZE 32
38#endif
39
40/*
41 * Define _STANDALONE then remove after.
42 */
43#define _STANDALONE 1
44
45#include <sys/cdefs.h>
46#include <sys/exec_elf.h>
47
48#undef _STANDALONE
49
50/**
51 ** Imported NetBSD ELF Specifics End.
52 **/
53
54/**
55 * Relocation trampoline relocation data.
56 */
57typedef struct rtems_rtl_mdreloc_trmap
58{
59  bool   parsing;     /**< The reloc records are being parsed. */
60  void*  tampolines;  /**< The trampoline memory. */
61  size_t size;        /**< The trampoline size. */
62} rtems_rtl_mdreloc_tramp;
63
64/**
65 * Maximum string length. This a read buffering limit rather than a
66 * specific ELF length. I hope this is ok as I am concerned about
67 * some C++ symbol lengths.
68 */
69#define RTEMS_RTL_ELF_STRING_MAX (256)
70
71/**
72 * Architecture specific handler to translate unknown section flags to RTL
73 * section flags. If this function returns 0 an error is raised.
74 *
75 * @param obj The object file being relocated.
76 * @param shdr The ELF section header.
77 * @retval 0 Unknown or unsupported flags.
78 * @retval uint32_t RTL object file flags.
79 */
80uint32_t rtems_rtl_elf_section_flags (const rtems_rtl_obj* obj,
81                                      const Elf_Shdr*      shdr);
82
83/**
84 * Architecture specific handler to parse the section and add any flags that
85 * may be need to handle the section.
86 *
87 * @param obj The object file being relocated.
88 * @param seciton The section index.
89 * @param name The name of the section
90 * @param shdr The ELF section header.
91 * @param flags The standard ELF parsed flags.
92 * @retval uint32_t Extra RTL object file flags.
93 */
94uint32_t rtems_rtl_elf_arch_parse_section (const rtems_rtl_obj* obj,
95                                           int                  section,
96                                           const char*          name,
97                                           const Elf_Shdr*      shdr,
98                                           const uint32_t       flags);
99
100/**
101 * Architecture specific handler to allocate a section. Some sections are
102 * specific to an architecture and need special allocators.
103 *
104 * @param obj The object file being relocated.
105 * @param sect The section data.
106 * @retval true The allocator was successful.
107 */
108bool rtems_rtl_elf_arch_section_alloc (const rtems_rtl_obj* obj,
109                                       rtems_rtl_obj_sect* sect);
110
111/**
112 * Architecture specific handler to free a section. Some sections are
113 * specific to an architecture and need special allocators.
114 *
115 * @param obj The object file being relocated.
116 * @param sect The section data.
117 * @retval true The allocator was successful.
118 */
119bool rtems_rtl_elf_arch_section_free (const rtems_rtl_obj* obj,
120                                      rtems_rtl_obj_sect* sect);
121
122/**
123 * Architecture specific handler to check is a relocation record's type is
124 * required to resolve a symbol.
125 *
126 * @param type The type field in the relocation record.
127 * @retval true The relocation record require symbol resolution.
128 * @retval false The relocation record does not require symbol resolution.
129 */
130bool rtems_rtl_elf_rel_resolve_sym (Elf_Word type);
131
132/**
133 * Architecture specific relocation maximum trampoline size. A trampoline entry
134 * of this size is allocated for each unresolved external.
135 *
136 * @return size_t The maximum size of a trampoline for this architecture.
137 */
138size_t rtems_rtl_elf_relocate_tramp_max_size (void);
139
140/**
141 * Architecture specific relocation trampoline handler compiled in for a
142 * specific architecture by the build system. The handler determines if the
143 * relocation record requires a trampoline.
144 *
145 * @param obj The object file being relocated.
146 * @param rel The ELF relocation record.
147 * @param sect The section of the object file the relocation is for.
148 * @param symname The symbol's name.
149 * @param syminfo The ELF symbol info field.
150 * @param symvalue If a symbol is referenced, this is the symbols value.
151 * @retval bool The relocation is valid.
152 * @retval bool The relocation is not valid.
153 */
154bool rtems_rtl_elf_relocate_rel_tramp (rtems_rtl_obj*            obj,
155                                       const Elf_Rel*            rel,
156                                       const rtems_rtl_obj_sect* sect,
157                                       const char*               symname,
158                                       const Elf_Byte            syminfo,
159                                       const Elf_Word            symvalue);
160
161/**
162 * Architecture specific relocation handler compiled in for a specific
163 * architecture by the build system. The handler applies the relocation
164 * to the target.
165 *
166 * @param obj The object file being relocated.
167 * @param rela The ELF addend relocation record.
168 * @param sect The section of the object file the relocation is for.
169 * @param symname The symbol's name.
170 * @param syminfo The ELF symbol info field.
171 * @param symvalue If a symbol is referenced, this is the symbols value.
172 * @retval bool The relocation is valid.
173 * @retval bool The relocation is not valid.
174 */
175bool rtems_rtl_elf_relocate_rela_tramp (rtems_rtl_obj*            obj,
176                                        const Elf_Rela*           rela,
177                                        const rtems_rtl_obj_sect* sect,
178                                        const char*               symname,
179                                        const Elf_Byte            syminfo,
180                                        const Elf_Word            symvalue);
181
182/**
183 * Architecture specific relocation handler compiled in for a specific
184 * architecture by the build system. The handler applies the relocation
185 * to the target.
186 *
187 * @param obj The object file being relocated.
188 * @param rel The ELF relocation record.
189 * @param sect The section of the object file the relocation is for.
190 * @param symname The symbol's name.
191 * @param syminfo The ELF symbol info field.
192 * @param symvalue If a symbol is referenced, this is the symbols value.
193 * @retval bool The relocation has been applied.
194 * @retval bool The relocation could not be applied.
195 */
196bool rtems_rtl_elf_relocate_rel (rtems_rtl_obj*            obj,
197                                 const Elf_Rel*            rel,
198                                 const rtems_rtl_obj_sect* sect,
199                                 const char*               symname,
200                                 const Elf_Byte            syminfo,
201                                 const Elf_Word            symvalue);
202
203/**
204 * Architecture specific relocation handler compiled in for a specific
205 * architecture by the build system. The handler applies the relocation
206 * to the target.
207 *
208 * @param obj The object file being relocated.
209 * @param rela The ELF addend relocation record.
210 * @param sect The section of the object file the relocation is for.
211 * @param symname The symbol's name.
212 * @param syminfo The ELF symbol info field.
213 * @param symvalue If a symbol is referenced, this is the symbols value.
214 * @retval bool The relocation has been applied.
215 * @retval bool The relocation could not be applied.
216 */
217bool rtems_rtl_elf_relocate_rela (rtems_rtl_obj*            obj,
218                                  const Elf_Rela*           rela,
219                                  const rtems_rtl_obj_sect* sect,
220                                  const char*               symname,
221                                  const Elf_Byte            syminfo,
222                                  const Elf_Word            symvalue);
223
224/**
225 * The ELF format check handler.
226 *
227 * @param obj The object being checked.
228 * @param fd The file descriptor.
229 */
230bool rtems_rtl_elf_file_check (rtems_rtl_obj* obj, int fd);
231
232/**
233 * The ELF format load handler.
234 *
235 * @param obj The object to load.
236 * @param fd The file descriptor.
237 */
238bool rtems_rtl_elf_file_load (rtems_rtl_obj* obj, int fd);
239
240/**
241 * The ELF format unload handler.
242 *
243 * @param obj The object to unload.
244 */
245bool rtems_rtl_elf_file_unload (rtems_rtl_obj* obj);
246
247/**
248 * The ELF format signature handler.
249 *
250 * @return rtems_rtl_loader_format* The format's signature.
251 */
252rtems_rtl_loader_format* rtems_rtl_elf_file_sig (void);
253
254#ifdef __cplusplus
255}
256#endif /* __cplusplus */
257
258#endif
Note: See TracBrowser for help on using the repository browser.