source: rtems/cpukit/libdl/rtl-mdreloc-moxie.c @ c130387

5
Last change on this file since c130387 was 30ea9bf, checked in by Joel Sherrill <joel.sherrill@…>, on 03/22/15 at 14:42:46

libdl/rtl-mdreloc-moxie.c: Fix printf() format warnings

  • Property mode set to 100644
File size: 2.6 KB
Line 
1
2#include <sys/cdefs.h>
3
4#include <errno.h>
5#include <stdio.h>
6#include <sys/types.h>
7#include <sys/stat.h>
8
9#include <rtems/rtl/rtl.h>
10#include "rtl-elf.h"
11#include "rtl-error.h"
12#include "rtl-trace.h"
13
14bool
15rtems_rtl_elf_rel_resolve_sym (Elf_Word type)
16{
17  return true;
18}
19
20bool
21rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t*      obj,
22                             const Elf_Rela*             rela,
23                             const rtems_rtl_obj_sect_t* sect,
24                             const char*                 symname,
25                             const Elf_Byte              syminfo,
26                             const Elf_Word              symvalue)
27{
28  Elf_Addr *where;
29  Elf_Sword tmp;
30
31  where = (Elf_Addr *)(sect->base + rela->r_offset);
32
33  /* Handle the not 4byte aligned address carefully */
34
35  switch (ELF_R_TYPE(rela->r_info)) {
36    case R_TYPE(NONE):
37      break;
38
39    case R_TYPE(32):
40      *(uint16_t *)where = ((symvalue + rela->r_addend) >> 16) & 0xffff;
41      *((uint16_t *)where + 1) = (symvalue + rela->r_addend) & 0xffff;
42
43      if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC)) {
44          printf("*where 0x%04x%04x\n", *((uint16_t *)where + 1), *(uint16_t *)where);
45      }
46      break;
47
48    case R_TYPE(PCREL10):
49      /* beq, bge, bgeu, bgt, bgtu, ble, bleu, blt, bltu, bne */
50      if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC)) {
51        printf("*where %x\n", *(uint16_t *)where);
52        printf("symvalue - where %x\n", (int)(symvalue - (Elf_Word)where));
53      }
54      tmp = (symvalue + rela->r_addend - ((Elf_Word)where + 2)); /* pc is the next instruction */
55      tmp = (Elf_Sword)tmp >> 1;
56      if (((Elf32_Sword)tmp > 0x1ff) || ((Elf32_Sword)tmp < -(Elf32_Sword)0x200)){
57        printf("Overflow for PCREL10: %ld exceed -0x200:0x1ff\n", tmp);
58        return false;
59      }
60
61      *(uint16_t *)where = (*(uint16_t *)where & 0xfc00) | (tmp & 0x3ff);
62
63      if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC)) {
64          printf("*where 0x%04x\n",  *(uint16_t *)where);
65      }
66
67      break;
68
69    default:
70      rtems_rtl_set_error (EINVAL, "rela type record not supported");
71      printf("Unsupported reloc types\n");
72      return false;
73  }
74
75  return true;
76}
77
78bool
79rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t*      obj,
80                            const Elf_Rel*              rel,
81                            const rtems_rtl_obj_sect_t* sect,
82                            const char*                 symname,
83                            const Elf_Byte              syminfo,
84                            const Elf_Word              symvalue)
85{
86  rtems_rtl_set_error (EINVAL, "rel type record not supported");
87  return false;
88}
Note: See TracBrowser for help on using the repository browser.