source: rtems/cpukit/libdl/rtl-mdreloc-h8300.c @ be50969

5
Last change on this file since be50969 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: 5.4 KB
Line 
1#include <sys/cdefs.h>
2
3#include <errno.h>
4#include <stdio.h>
5#include <sys/types.h>
6#include <sys/stat.h>
7
8#include <rtems/rtl/rtl.h>
9#include "rtl-elf.h"
10#include "rtl-error.h"
11#include <rtems/rtl/rtl-trace.h>
12#include "rtl-unwind.h"
13#include "rtl-unwind-dw2.h"
14
15uint32_t
16rtems_rtl_elf_section_flags (const rtems_rtl_obj* obj,
17                             const Elf_Shdr*      shdr)
18{
19  return 0;
20}
21
22uint32_t
23rtems_rtl_elf_arch_parse_section (const rtems_rtl_obj* obj,
24                                  int                  section,
25                                  const char*          name,
26                                  const Elf_Shdr*      shdr,
27                                  const uint32_t       flags)
28{
29  (void) obj;
30  (void) section;
31  (void) name;
32  (void) shdr;
33  return flags;
34}
35
36bool
37rtems_rtl_elf_arch_section_alloc (const rtems_rtl_obj* obj,
38                                  rtems_rtl_obj_sect*  sect)
39{
40  (void) obj;
41  (void) sect;
42  return false;
43}
44
45bool
46rtems_rtl_elf_arch_section_free (const rtems_rtl_obj* obj,
47                                  rtems_rtl_obj_sect*  sect)
48{
49  (void) obj;
50  (void) sect;
51  return false;
52}
53
54bool
55rtems_rtl_elf_rel_resolve_sym (Elf_Word type)
56{
57  return true;
58}
59
60size_t
61rtems_rtl_elf_relocate_tramp_max_size (void)
62{
63  /*
64   * Disable by returning 0.
65   */
66  return 0;
67}
68
69bool
70rtems_rtl_elf_relocate_rela_tramp (rtems_rtl_obj*            obj,
71                                   const Elf_Rela*           rela,
72                                   const rtems_rtl_obj_sect* sect,
73                                   const char*               symname,
74                                   const Elf_Byte            syminfo,
75                                   const Elf_Word            symvalue)
76{
77  (void) obj;
78  (void) rela;
79  (void) sect;
80  (void) symname;
81  (void) syminfo;
82  (void) symvalue;
83  return true;
84}
85
86bool
87rtems_rtl_elf_relocate_rela (rtems_rtl_obj*            obj,
88                             const Elf_Rela*           rela,
89                             const rtems_rtl_obj_sect* sect,
90                             const char*               symname,
91                             const Elf_Byte            syminfo,
92                             const Elf_Word            symvalue)
93{
94  Elf_Addr *where;
95  Elf_Word tmp;
96
97  where = (Elf_Addr *)(sect->base + rela->r_offset);
98
99  if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC)) {
100      printf("rela relocation type is %ld\n", ELF_R_TYPE(rela->r_info));
101      printf("relocated address 0x%08lx\n", (Elf_Addr)where);
102  }
103
104  tmp = symvalue;
105  switch (ELF_R_TYPE(rela->r_info)) {
106    case R_TYPE(NONE):
107      break;
108
109    case R_TYPE(DIR16):
110      *(uint16_t *)where += symvalue + rela->r_addend;
111      break;
112
113    case R_TYPE(DIR32):
114    case R_TYPE(DIR32A16):
115      *where += symvalue + rela->r_addend;
116      break;
117
118    case R_TYPE(DIR24A8):
119      if (ELF32_R_SYM(rela->r_info))
120        *where += symvalue + rela->r_addend;
121      break;
122
123    case R_TYPE(DIR24R8):
124      where = (uint32_t *)((uint32_t)where - 1);
125      *where = (*where & 0xff000000) | ((*where & 0xffffff) + symvalue + rela->r_addend);
126      break;
127
128    case R_TYPE(PCREL8):
129      /* bcc instruction */
130      tmp = symvalue + rela->r_addend - (Elf_Addr)where - 1;
131      if (((Elf32_Sword)tmp > 0x7f) || ((Elf32_Sword)tmp < -(Elf32_Sword)0x80)){
132        printf("PCREL8 overflow\n");
133          return false;
134      } else {
135        *(uint8_t *)where = tmp;
136      }
137      break;
138
139    case R_TYPE(PCREL16):
140      /* bcc instruction */
141      tmp = symvalue + rela->r_addend - (Elf_Addr)where - 2;
142      if (((Elf32_Sword)tmp > 0x7fff) || ((Elf32_Sword)tmp < -(Elf32_Sword)0x8000)){
143        printf("PCREL16 overflow\n");
144       return false;
145      } else {
146       *(uint16_t *)where = tmp;
147      }
148      break;
149
150    default:
151      rtems_rtl_set_error (EINVAL, "rela type record not supported");
152      printf("Unsupported reloc types\n");
153      return false;
154  }
155  return true;
156}
157
158bool
159rtems_rtl_elf_relocate_rel_tramp (rtems_rtl_obj*           obj,
160                                  const Elf_Rel*            rel,
161                                  const rtems_rtl_obj_sect* sect,
162                                  const char*               symname,
163                                  const Elf_Byte            syminfo,
164                                  const Elf_Word            symvalue)
165{
166  (void) obj;
167  (void) rel;
168  (void) sect;
169  (void) symname;
170  (void) syminfo;
171  (void) symvalue;
172  rtems_rtl_set_error (EINVAL, "rel type record not supported");
173  return false;
174}
175
176bool
177rtems_rtl_elf_relocate_rel (rtems_rtl_obj*            obj,
178                            const Elf_Rel*            rel,
179                            const rtems_rtl_obj_sect* sect,
180                            const char*               symname,
181                            const Elf_Byte            syminfo,
182                            const Elf_Word            symvalue)
183{
184  (void) obj;
185  (void) rel;
186  (void) sect;
187  (void) symname;
188  (void) syminfo;
189  (void) symvalue;
190  rtems_rtl_set_error (EINVAL, "rel type record not supported");
191  return false;
192}
193
194bool
195rtems_rtl_elf_unwind_parse (const rtems_rtl_obj* obj,
196                            const char*          name,
197                            uint32_t             flags)
198{
199  return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags);
200}
201
202bool
203rtems_rtl_elf_unwind_register (rtems_rtl_obj* obj)
204{
205  return rtems_rtl_elf_unwind_dw2_register (obj);
206}
207
208bool
209rtems_rtl_elf_unwind_deregister (rtems_rtl_obj* obj)
210{
211  return rtems_rtl_elf_unwind_dw2_deregister (obj);
212}
Note: See TracBrowser for help on using the repository browser.