source: rtems/cpukit/libdl/rtl-elf.h @ 03139d5b

5
Last change on this file since 03139d5b was 03139d5b, checked in by Chris Johns <chrisj@…>, on 11/20/18 at 03:56:11

libdl: Add object file dependencies to track references

Tracking references lets us manage when an object file can be
unloaded. If an object file has references to it, it cannot be
unloaded.

Modules that depend on each other cannot be unloaded.

Updates #3605

  • Property mode set to 100644
File size: 4.5 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 * Maximum string length. This a read buffering limit rather than a
56 * specific ELF length. I hope this is ok as I am concerned about
57 * some C++ symbol lengths.
58 */
59#define RTEMS_RTL_ELF_STRING_MAX (256)
60
61/**
62 * Architecture specific handler to translate unknown section flags to RTL
63 * section flags.
64 *
65 * @param obj The object file being relocated.
66 * @param shdr The ELF section header.
67 * @retval 0 Unknown or unsupported flags.
68 * @retval uint32_t RTL object file flags.
69 */
70uint32_t rtems_rtl_elf_section_flags (const rtems_rtl_obj* obj,
71                                      const Elf_Shdr*      shdr);
72
73/**
74 * Architecture specific handler to check is a relocation record's type is
75 * required to resolve a symbol.
76 *
77 * @param type The type field in the relocation record.
78 * @retval true The relocation record require symbol resolution.
79 * @retval false The relocation record does not require symbol resolution.
80 */
81bool rtems_rtl_elf_rel_resolve_sym (Elf_Word type);
82
83/**
84 * Architecture specific relocation handler compiled in for a specific
85 * architecture by the build system. The handler applies the relocation
86 * to the target.
87 *
88 * @param obj The object file being relocated.
89 * @param rel The ELF relocation record.
90 * @param sect The section of the object file the relocation is for.
91 * @param symname The symbol's name.
92 * @param syminfo The ELF symbol info field.
93 * @param symvalue If a symbol is referenced, this is the symbols value.
94 * @retval bool The relocation has been applied.
95 * @retval bool The relocation could not be applied.
96 */
97bool rtems_rtl_elf_relocate_rel (const rtems_rtl_obj*      obj,
98                                 const Elf_Rel*            rel,
99                                 const rtems_rtl_obj_sect* sect,
100                                 const char*               symname,
101                                 const Elf_Byte            syminfo,
102                                 const Elf_Word            symvalue);
103
104/**
105 * Architecture specific relocation handler compiled in for a specific
106 * architecture by the build system. The handler applies the relocation
107 * to the target.
108 *
109 * @param obj The object file being relocated.
110 * @param rela The ELF addend relocation record.
111 * @param sect The section of the object file the relocation is for.
112 * @param symname The symbol's name.
113 * @param syminfo The ELF symbol info field.
114 * @param symvalue If a symbol is referenced, this is the symbols value.
115 * @retval bool The relocation has been applied.
116 * @retval bool The relocation could not be applied.
117 */
118bool rtems_rtl_elf_relocate_rela (const rtems_rtl_obj*      obj,
119                                  const Elf_Rela*           rela,
120                                  const rtems_rtl_obj_sect* sect,
121                                  const char*               symname,
122                                  const Elf_Byte            syminfo,
123                                  const Elf_Word            symvalue);
124
125/**
126 * The ELF format check handler.
127 *
128 * @param obj The object being checked.
129 * @param fd The file descriptor.
130 */
131bool rtems_rtl_elf_file_check (rtems_rtl_obj* obj, int fd);
132
133/**
134 * The ELF format load handler.
135 *
136 * @param obj The object to load.
137 * @param fd The file descriptor.
138 */
139bool rtems_rtl_elf_file_load (rtems_rtl_obj* obj, int fd);
140
141/**
142 * The ELF format unload handler.
143 *
144 * @param obj The object to unload.
145 */
146bool rtems_rtl_elf_file_unload (rtems_rtl_obj* obj);
147
148/**
149 * The ELF format signature handler.
150 *
151 * @return rtems_rtl_loader_format* The format's signature.
152 */
153rtems_rtl_loader_format* rtems_rtl_elf_file_sig (void);
154
155#ifdef __cplusplus
156}
157#endif /* __cplusplus */
158
159#endif
Note: See TracBrowser for help on using the repository browser.