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

5
Last change on this file since 4408603 was f59d435d, checked in by Chris Johns <chrisj@…>, on 04/12/18 at 07:46:49

libdl: Remove _t from all structures as this is reserved for the standards

  • Property mode set to 100644
File size: 3.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
22bool
23rtems_rtl_elf_rel_resolve_sym (Elf_Word type)
24{
25  return true;
26}
27
28bool
29rtems_rtl_elf_relocate_rela (const rtems_rtl_obj*      obj,
30                             const Elf_Rela*           rela,
31                             const rtems_rtl_obj_sect* sect,
32                             const char*               symname,
33                             const Elf_Byte            syminfo,
34                             const Elf_Word            symvalue)
35{
36  Elf_Addr *where;
37  Elf_Word tmp;
38
39  where = (Elf_Addr *)(sect->base + rela->r_offset);
40
41  if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC)) {
42      printf("rela relocation type is %ld\n", ELF_R_TYPE(rela->r_info));
43      printf("relocated address 0x%08lx\n", (Elf_Addr)where);
44  }
45
46  tmp = symvalue;
47  switch (ELF_R_TYPE(rela->r_info)) {
48    case R_TYPE(NONE):
49      break;
50
51    case R_TYPE(DIR16):
52      *(uint16_t *)where += symvalue + rela->r_addend;
53      break;
54
55    case R_TYPE(DIR32):
56    case R_TYPE(DIR32A16):
57      *where += symvalue + rela->r_addend;
58      break;
59
60    case R_TYPE(DIR24A8):
61      if (ELF32_R_SYM(rela->r_info))
62        *where += symvalue + rela->r_addend;
63      break;
64
65    case R_TYPE(DIR24R8):
66      where = (uint32_t *)((uint32_t)where - 1);
67      *where = (*where & 0xff000000) | ((*where & 0xffffff) + symvalue + rela->r_addend);
68      break;
69
70    case R_TYPE(PCREL8):
71      /* bcc instruction */
72      tmp = symvalue + rela->r_addend - (Elf_Addr)where - 1;
73      if (((Elf32_Sword)tmp > 0x7f) || ((Elf32_Sword)tmp < -(Elf32_Sword)0x80)){
74        printf("PCREL8 overflow\n");
75          return false;
76      } else {
77        *(uint8_t *)where = tmp;
78      }
79      break;
80
81    case R_TYPE(PCREL16):
82      /* bcc instruction */
83      tmp = symvalue + rela->r_addend - (Elf_Addr)where - 2;
84      if (((Elf32_Sword)tmp > 0x7fff) || ((Elf32_Sword)tmp < -(Elf32_Sword)0x8000)){
85        printf("PCREL16 overflow\n");
86       return false;
87      } else {
88       *(uint16_t *)where = tmp;
89      }
90      break;
91
92    default:
93      rtems_rtl_set_error (EINVAL, "rela type record not supported");
94      printf("Unsupported reloc types\n");
95      return false;
96  }
97  return true;
98}
99
100bool
101rtems_rtl_elf_relocate_rel (const rtems_rtl_obj*      obj,
102                            const Elf_Rel*            rel,
103                            const rtems_rtl_obj_sect* sect,
104                            const char*               symname,
105                            const Elf_Byte            syminfo,
106                            const Elf_Word            symvalue)
107{
108  rtems_rtl_set_error (EINVAL, "rel type record not supported");
109  return false;
110}
111
112bool
113rtems_rtl_elf_unwind_parse (const rtems_rtl_obj* obj,
114                            const char*          name,
115                            uint32_t             flags)
116{
117  return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags);
118}
119
120bool
121rtems_rtl_elf_unwind_register (rtems_rtl_obj* obj)
122{
123  return rtems_rtl_elf_unwind_dw2_register (obj);
124}
125
126bool
127rtems_rtl_elf_unwind_deregister (rtems_rtl_obj* obj)
128{
129  return rtems_rtl_elf_unwind_dw2_deregister (obj);
130}
Note: See TracBrowser for help on using the repository browser.