Changeset d8c70ba6 in rtems


Ignore:
Timestamp:
01/15/19 06:47:41 (5 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
5, master
Children:
194eb403
Parents:
4408603
git-author:
Chris Johns <chrisj@…> (01/15/19 06:47:41)
git-committer:
Chris Johns <chrisj@…> (02/08/19 23:06:34)
Message:

libdl: Add support for trampolines

  • Trampolines or fixups for veneers provide long jump support for instruciton sets that implement short relative address branches. The linker provides trampolines when creating a static image. This patch adds trampoline support to libdl and the ARM architecture.
  • The dl09 test requires enough memory so modules are outside the relative branch instruction ranges for the architecture.

Updates #3685

Files:
15 added
19 edited

Legend:

Unmodified
Added
Removed
  • cpukit/include/rtems/rtl/rtl-obj.h

    r4408603 rd8c70ba6  
    11/*
    2  *  COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org>
     2 *  COPYRIGHT (c) 2012,2019 Chris Johns <chrisj@rtems.org>
    33 *
    44 *  The license and distribution terms for this file may be
     
    221221  uint32_t            obj_num;      /**< The count of elf files in an rtl
    222222                                     *   obj. */
     223  void*               trampoline;   /**< Trampoline memory. Used for fixups or
     224                                     *   veneers */
     225  size_t              tramp_size;   /**< Size of the tramopline memory. */
     226  void*               tramp_brk;    /**< Trampoline memory allocator. MD
     227                                     *   relocators can take memory from the
     228                                     *   break upto the size. */
    223229  struct link_map*    linkmap;      /**< For GDB. */
    224230  void*               loader;       /**< The file details specific to a
     
    351357  return (sym >= obj->global_table &&
    352358          sym < (obj->global_table + obj->global_syms));
     359}
     360
     361/**
     362 * Is there space in the trampoline memory for a trapoline.
     363 *
     364 * @param obj The object file's descriptor to check for available space.
     365 * @param size The size to be allocated.
     366 * @retval bool Returns @true if the space is available.
     367 */
     368static inline bool rtems_rtl_obj_has_ramp_space (const rtems_rtl_obj* obj,
     369                                                 const size_t         size)
     370{
     371  return (obj->trampoline != NULL &&
     372          ((obj->tramp_brk - obj->trampoline) + size) <= obj->tramp_size);
    353373}
    354374
     
    478498
    479499/**
     500 * Allocate a table for trampoline fixup calls.
     501 *
     502 * @param obj The object file's descriptor.
     503 * @retval true The table was allocated.
     504 * @retval false The alloction failed.
     505 */
     506bool rtems_rtl_obj_alloc_trampoline (rtems_rtl_obj* obj);
     507
     508/**
     509 * Erase the object file descriptor's trampoline table..
     510 *
     511 * @param obj The object file's descriptor.
     512 */
     513void rtems_rtl_obj_erase_trampoline (rtems_rtl_obj* obj);
     514
     515/**
    480516 * Allocate a table for dependent objects.
    481517 *
  • cpukit/libdl/rtl-elf.c

    r4408603 rd8c70ba6  
    8888    *symbol = rtems_rtl_symbol_obj_find (obj, symname);
    8989    if (!*symbol)
    90     {
    91       rtems_rtl_set_error (EINVAL, "global symbol not found: %s", symname);
    92       return false;
    93     }
     90      return false;
    9491
    9592    *value = (Elf_Addr) (*symbol)->value;
     
    10198  sect = rtems_rtl_obj_find_section_by_index (obj, sym->st_shndx);
    10299  if (!sect)
    103   {
    104     rtems_rtl_set_error (EINVAL, "reloc symbol's section not found");
    105     return false;
    106   }
     100    return false;
    107101
    108102  *value = sym->st_value + (Elf_Addr) sect->base;
     
    146140{
    147141  rtems_rtl_elf_reloc_data* rd = (rtems_rtl_elf_reloc_data*) data;
     142
     143  /*
     144   * Check the reloc record to see if a trampoline is needed.
     145   */
     146  if (is_rela)
     147  {
     148    const Elf_Rela* rela = (const Elf_Rela*) relbuf;
     149    if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC))
     150      printf ("rtl: rela tramp: sym:%s(%d)=%08jx type:%d off:%08jx addend:%d\n",
     151              symname, (int) ELF_R_SYM (rela->r_info),
     152              (uintmax_t) symvalue, (int) ELF_R_TYPE (rela->r_info),
     153              (uintmax_t) rela->r_offset, (int) rela->r_addend);
     154    if (!rtems_rtl_elf_relocate_rela_tramp (obj, rela, targetsect,
     155                                            symname, sym->st_info, symvalue))
     156      return false;
     157  }
     158  else
     159  {
     160    const Elf_Rel* rel = (const Elf_Rel*) relbuf;
     161    if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC))
     162      printf ("rtl: rel tramp: sym:%s(%d)=%08jx type:%d off:%08jx\n",
     163              symname, (int) ELF_R_SYM (rel->r_info),
     164              (uintmax_t) symvalue, (int) ELF_R_TYPE (rel->r_info),
     165              (uintmax_t) rel->r_offset);
     166    if (!rtems_rtl_elf_relocate_rel_tramp (obj, rel, targetsect,
     167                                           symname, sym->st_info, symvalue))
     168      return false;
     169  }
     170
    148171  /*
    149172   * If the symbol has been resolved and there is a symbol name it is a global
     
    154177    ++rd->unresolved;
    155178  }
    156   else if (resolved && symname != NULL)
     179  else if (symname != NULL)
    157180  {
    158181    /*
     
    555578
    556579  return true;
     580}
     581
     582static bool
     583rtems_rtl_elf_alloc_trampoline (rtems_rtl_obj* obj, size_t unresolved)
     584{
     585  /*
     586   * Add on enough space to handle the unresolved externals that need to be
     587   * resolved at some point in time. They could all require fixups and
     588   * trampolines.
     589   */
     590  obj->tramp_size +=
     591    rtems_rtl_elf_relocate_tramp_max_size () * unresolved;
     592  return rtems_rtl_obj_alloc_trampoline (obj);
    557593}
    558594
     
    12981334    return false;
    12991335
     1336  /*
     1337   * Parse the relocation records. It lets us know how many dependents
     1338   * and fixup trampolines there are.
     1339   */
    13001340  if (!rtems_rtl_obj_relocate (obj, fd, rtems_rtl_elf_relocs_parser, &relocs))
    13011341    return false;
    13021342
    13031343  if (!rtems_rtl_elf_dependents (obj, &relocs))
     1344    return false;
     1345
     1346  if (!rtems_rtl_elf_alloc_trampoline (obj, relocs.unresolved))
    13041347    return false;
    13051348
  • cpukit/libdl/rtl-elf.h

    r4408603 rd8c70ba6  
    5353
    5454/**
     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/**
    5565 * Maximum string length. This a read buffering limit rather than a
    5666 * specific ELF length. I hope this is ok as I am concerned about
     
    8292
    8393/**
     94 * Architecture specific relocation maximum trampoline size. A trampoline entry
     95 * of this size is allocated for each unresolved external.
     96 *
     97 * @return size_t The maximum size of a trampoline for this architecture.
     98 */
     99size_t rtems_rtl_elf_relocate_tramp_max_size (void);
     100
     101/**
     102 * Architecture specific relocation trampoline handler compiled in for a
     103 * specific architecture by the build system. The handler determines if the
     104 * relocation record requires a trampoline.
     105 *
     106 * @param obj The object file being relocated.
     107 * @param rel The ELF relocation record.
     108 * @param sect The section of the object file the relocation is for.
     109 * @param symname The symbol's name.
     110 * @param syminfo The ELF symbol info field.
     111 * @param symvalue If a symbol is referenced, this is the symbols value.
     112 * @retval bool The relocation is valid.
     113 * @retval bool The relocation is not valid.
     114 */
     115bool rtems_rtl_elf_relocate_rel_tramp (rtems_rtl_obj*            obj,
     116                                       const Elf_Rel*            rel,
     117                                       const rtems_rtl_obj_sect* sect,
     118                                       const char*               symname,
     119                                       const Elf_Byte            syminfo,
     120                                       const Elf_Word            symvalue);
     121
     122/**
    84123 * Architecture specific relocation handler compiled in for a specific
    85124 * architecture by the build system. The handler applies the relocation
     
    87126 *
    88127 * @param obj The object file being relocated.
     128 * @param rela The ELF addend relocation record.
     129 * @param sect The section of the object file the relocation is for.
     130 * @param symname The symbol's name.
     131 * @param syminfo The ELF symbol info field.
     132 * @param symvalue If a symbol is referenced, this is the symbols value.
     133 * @retval bool The relocation is valid.
     134 * @retval bool The relocation is not valid.
     135 */
     136bool rtems_rtl_elf_relocate_rela_tramp (rtems_rtl_obj*            obj,
     137                                        const Elf_Rela*           rela,
     138                                        const rtems_rtl_obj_sect* sect,
     139                                        const char*               symname,
     140                                        const Elf_Byte            syminfo,
     141                                        const Elf_Word            symvalue);
     142
     143/**
     144 * Architecture specific relocation handler compiled in for a specific
     145 * architecture by the build system. The handler applies the relocation
     146 * to the target.
     147 *
     148 * @param obj The object file being relocated.
    89149 * @param rel The ELF relocation record.
    90150 * @param sect The section of the object file the relocation is for.
     
    95155 * @retval bool The relocation could not be applied.
    96156 */
    97 bool rtems_rtl_elf_relocate_rel (const rtems_rtl_obj*      obj,
     157bool rtems_rtl_elf_relocate_rel (rtems_rtl_obj*            obj,
    98158                                 const Elf_Rel*            rel,
    99159                                 const rtems_rtl_obj_sect* sect,
     
    116176 * @retval bool The relocation could not be applied.
    117177 */
    118 bool rtems_rtl_elf_relocate_rela (const rtems_rtl_obj*      obj,
     178bool rtems_rtl_elf_relocate_rela (rtems_rtl_obj*            obj,
    119179                                  const Elf_Rela*           rela,
    120180                                  const rtems_rtl_obj_sect* sect,
  • cpukit/libdl/rtl-mdreloc-arm.c

    r4408603 rd8c70ba6  
    3434load_ptr(void *where)
    3535{
    36         Elf_Addr res;
    37 
    38         memcpy(&res, where, sizeof(res));
    39 
    40         return (res);
     36  Elf_Addr res;
     37
     38  memcpy(&res, where, sizeof(res));
     39
     40  return (res);
    4141}
    4242
     
    4444store_ptr(void *where, Elf_Addr val)
    4545{
    46 
    47         memcpy(where, &val, sizeof(val));
     46  memcpy(where, &val, sizeof(val));
    4847}
    4948
     
    6867}
    6968
     69static void*
     70set_veneer(void* tramopline, Elf_Addr target)
     71{
     72  /*
     73   * http://shell-storm.org/online/Online-Assembler-and-Disassembler/
     74   *
     75   *  ldr.w pc, [pc]
     76   */
     77  uint32_t* tramp = (uint32_t*) tramopline;
     78  *tramp++ = 0xf000f8df;
     79  *tramp++ = (uint32_t) target;
     80  return tramp;
     81}
     82
     83static size_t
     84get_veneer_size(int type)
     85{
     86  (void) type;
     87  return 8;
     88}
     89
     90size_t
     91rtems_rtl_elf_relocate_tramp_max_size (void)
     92{
     93  return 8;
     94}
     95
    7096uint32_t
    7197rtems_rtl_elf_section_flags (const rtems_rtl_obj* obj,
     
    85111
    86112bool
    87 rtems_rtl_elf_relocate_rela (const rtems_rtl_obj*      obj,
     113rtems_rtl_elf_relocate_rela_tramp (rtems_rtl_obj*            obj,
     114                                   const Elf_Rela*           rela,
     115                                   const rtems_rtl_obj_sect* sect,
     116                                   const char*               symname,
     117                                   const Elf_Byte            syminfo,
     118                                   const Elf_Word            symvalue)
     119{
     120  (void) obj;
     121  (void) rela;
     122  (void) sect;
     123  (void) symname;
     124  (void) syminfo;
     125  (void) symvalue;
     126  rtems_rtl_set_error (EINVAL, "rela type record not supported");
     127  return false;
     128}
     129
     130bool
     131rtems_rtl_elf_relocate_rela (rtems_rtl_obj*            obj,
    88132                             const Elf_Rela*           rela,
    89133                             const rtems_rtl_obj_sect* sect,
     
    92136                             const Elf_Word            symvalue)
    93137{
     138  (void) obj;
     139  (void) rela;
     140  (void) sect;
     141  (void) symname;
     142  (void) syminfo;
     143  (void) symvalue;
    94144  rtems_rtl_set_error (EINVAL, "rela type record not supported");
    95145  return false;
    96146}
    97147
    98 bool
    99 rtems_rtl_elf_relocate_rel (const rtems_rtl_obj*      obj,
    100                             const Elf_Rel*            rel,
    101                             const rtems_rtl_obj_sect* sect,
    102                             const char*               symname,
    103                             const Elf_Byte            syminfo,
    104                             const Elf_Word            symvalue)
     148static bool
     149rtems_rtl_elf_relor_rel (rtems_rtl_obj*            obj,
     150                         const Elf_Rel*            rel,
     151                         const rtems_rtl_obj_sect* sect,
     152                         const char*               symname,
     153                         const Elf_Byte            syminfo,
     154                         const Elf_Word            symvalue,
     155                         const bool                parsing)
    105156{
    106157  Elf_Addr *where;
     
    143194
    144195      if (((Elf_Sword)tmp > 0x7fffff) || ((Elf_Sword)tmp < -0x800000)) {
    145         printf("CALL/JUMP24 Overflow\n");
    146         return false;
    147       }
    148 
    149       *where = (*where & 0xff000000) | (tmp & 0xffffff);
    150 
    151       if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC))
    152         printf ("rtl: JUMP24/PC24/CALL %p @ %p in %s\n",
    153                 (void *)*where, where, rtems_rtl_obj_oname (obj));
    154 
     196        Elf_Word tramp_addr;
     197        size_t   tramp_size = get_veneer_size(ELF_R_TYPE(rel->r_info));
     198
     199        if (parsing) {
     200          obj->tramp_size += tramp_size;
     201          return true;
     202        }
     203
     204        if (!rtems_rtl_obj_has_ramp_space (obj, tramp_size)) {
     205          rtems_rtl_set_error (EINVAL,
     206                               "%s: CALL/JUMP24: overflow: no tramp memory",
     207                               sect->name);
     208          return false;
     209        }
     210
     211        tramp_addr = ((Elf_Addr) obj->tramp_brk) | (symvalue & 1);
     212        obj->tramp_brk = set_veneer(obj->tramp_brk, symvalue);
     213
     214        tmp = tramp_addr + (addend << 2) - (Elf_Addr)where;
     215        tmp = (Elf_Sword)tmp >> 2;
     216      }
     217
     218      if (!parsing) {
     219        *where = (*where & 0xff000000) | (tmp & 0xffffff);
     220
     221        if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC))
     222          printf ("rtl: JUMP24/PC24/CALL %p @ %p in %s\n",
     223                  (void *)*where, where, rtems_rtl_obj_oname (obj));
     224      }
    155225      break;
    156226
    157227    case R_TYPE(V4BX):
    158228      /* Miscellaneous, ignore */
    159       if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC)) {
     229      if (!parsing && rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC)) {
    160230        printf ("rtl: V4BX %p @ %p in %s\n",
    161231                (void *)*where, where, rtems_rtl_obj_oname (obj));
     
    183253      }
    184254
    185       *where = (insn & 0xfff0f000) | ((tmp & 0xf000) << 4) | (tmp & 0xfff);
    186 
    187       if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC))
    188         printf ("rtl: MOVT_ABS/MOVW_ABS_NC %p @ %p in %s\n",
    189                 (void *)*where, where, rtems_rtl_obj_oname (obj));
    190       break;
    191 
     255      if (!parsing) {
     256        *where = (insn & 0xfff0f000) | ((tmp & 0xf000) << 4) | (tmp & 0xfff);
     257
     258        if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC))
     259          printf ("rtl: MOVT_ABS/MOVW_ABS_NC %p @ %p in %s\n",
     260                  (void *)*where, where, rtems_rtl_obj_oname (obj));
     261      }
     262      break;
    192263
    193264    case R_TYPE(REL32):     /* word32 (S + A) | T - P */
     
    197268    case R_TYPE(TARGET1):   /* Equivalent to ABS32 */
    198269    case R_TYPE(TARGET2):   /* Equivalent to REL32 */
    199       if (__predict_true(RELOC_ALIGNED_P(where))) {
    200         tmp = *where + symvalue;
    201         if (isThumb(symvalue))
    202           tmp |= 1;
    203         if (ELF_R_TYPE(rel->r_info) == R_TYPE(REL32) ||
    204             ELF_R_TYPE(rel->r_info) == R_TYPE(TARGET2))
    205           tmp -= (Elf_Addr)where;
    206         else if (ELF_R_TYPE(rel->r_info) == R_TYPE(PREL31))
    207           tmp = sign_extend31(tmp - (Elf_Addr)where);
    208         *where = tmp;
    209       } else {
    210         tmp = load_ptr(where) + symvalue;
    211         if (isThumb(symvalue))
    212           tmp |= 1;
    213         if (ELF_R_TYPE(rel->r_info) == R_TYPE(REL32) ||
    214             ELF_R_TYPE(rel->r_info) == R_TYPE(TARGET2))
    215           tmp -= (Elf_Addr)where;
    216         else if (ELF_R_TYPE(rel->r_info) == R_TYPE(PREL31))
    217           tmp = sign_extend31(tmp - (Elf_Addr)where);
    218         store_ptr(where, tmp);
    219       }
    220 
    221       if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC))
    222         printf ("rtl: REL32/ABS32/GLOB_DAT/PREL31/TARGET2 %p @ %p in %s\n",
    223                 (void *)tmp, where, rtems_rtl_obj_oname (obj));
     270      if (!parsing) {
     271        if (__predict_true(RELOC_ALIGNED_P(where))) {
     272          tmp = *where + symvalue;
     273          if (isThumb(symvalue))
     274            tmp |= 1;
     275          if (ELF_R_TYPE(rel->r_info) == R_TYPE(REL32) ||
     276              ELF_R_TYPE(rel->r_info) == R_TYPE(TARGET2))
     277            tmp -= (Elf_Addr)where;
     278          else if (ELF_R_TYPE(rel->r_info) == R_TYPE(PREL31))
     279            tmp = sign_extend31(tmp - (Elf_Addr)where);
     280          if (!parsing) {
     281            *where = tmp;
     282          }
     283        } else {
     284          tmp = load_ptr(where) + symvalue;
     285          if (isThumb(symvalue))
     286            tmp |= 1;
     287          if (ELF_R_TYPE(rel->r_info) == R_TYPE(REL32) ||
     288              ELF_R_TYPE(rel->r_info) == R_TYPE(TARGET2))
     289            tmp -= (Elf_Addr)where;
     290          else if (ELF_R_TYPE(rel->r_info) == R_TYPE(PREL31))
     291            tmp = sign_extend31(tmp - (Elf_Addr)where);
     292          store_ptr(where, tmp);
     293        }
     294
     295        if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC))
     296          printf ("rtl: REL32/ABS32/GLOB_DAT/PREL31/TARGET2 %p @ %p in %s\n",
     297                  (void *)tmp, where, rtems_rtl_obj_oname (obj));
     298      }
    224299      break;
    225300
    226301    case R_TYPE(THM_MOVT_ABS):
    227302    case R_TYPE(THM_MOVW_ABS_NC):
    228       upper_insn = *(uint16_t *)where;
    229       lower_insn = *((uint16_t *)where + 1);
    230 
    231       addend = ((upper_insn & 0x000f) << 12) | ((upper_insn & 0x0400) << 1) |
    232                ((lower_insn & 0x7000) >> 4) | (lower_insn & 0x00ff);
    233       addend = (addend ^ 0x8000) - 0x8000;
    234 
    235       tmp = addend + symvalue;
    236       if (ELF32_R_TYPE(rel->r_info) == R_ARM_THM_MOVT_ABS)
    237         tmp >>= 16;
    238 
    239       *(uint16_t *)where = (uint16_t)((upper_insn & 0xfbf0) |
    240                                      ((tmp & 0xf000) >> 12) |
    241                                      ((tmp & 0x0800) >> 1));
    242       *((uint16_t *)where + 1) = (uint16_t)((lower_insn & 0x8f00) |
    243                                            ((tmp & 0x0700) << 4) |
    244                                            (tmp & 0x00ff));
    245 
    246       if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC)) {
    247         printf ("rtl: THM_MOVT_ABS/THM_MOVW_ABS_NC %p @ %p in %s\n",
    248                 (void *)*where, where, rtems_rtl_obj_oname (obj));
    249       }
    250 
     303      if (!parsing) {
     304        upper_insn = *(uint16_t *)where;
     305        lower_insn = *((uint16_t *)where + 1);
     306
     307        addend = ((upper_insn & 0x000f) << 12) | ((upper_insn & 0x0400) << 1) |
     308          ((lower_insn & 0x7000) >> 4) | (lower_insn & 0x00ff);
     309        addend = (addend ^ 0x8000) - 0x8000;
     310
     311        tmp = addend + symvalue;
     312        if (ELF32_R_TYPE(rel->r_info) == R_ARM_THM_MOVT_ABS)
     313          tmp >>= 16;
     314
     315        *(uint16_t *)where = (uint16_t)((upper_insn & 0xfbf0) |
     316                                        ((tmp & 0xf000) >> 12) |
     317                                        ((tmp & 0x0800) >> 1));
     318        *((uint16_t *)where + 1) = (uint16_t)((lower_insn & 0x8f00) |
     319                                              ((tmp & 0x0700) << 4) |
     320                                              (tmp & 0x00ff));
     321
     322        if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC)) {
     323          printf ("rtl: THM_MOVT_ABS/THM_MOVW_ABS_NC %p @ %p in %s\n",
     324                  (void *)*where, where, rtems_rtl_obj_oname (obj));
     325        }
     326      }
    251327      break;
    252328
     
    279355
    280356      if (((Elf_Sword)tmp > 0x7fffff) || ((Elf_Sword)tmp < -0x800000)) {
    281         printf("THM_CALL/JUMP24 overflow\n");
    282         return false;
    283       }
    284 
    285       sign = (tmp >> 24) & 1;
    286       *(uint16_t *)where = (uint16_t)((upper_insn & 0xf800) | (sign << 10) |
    287                                      ((tmp >> 12) & 0x3ff));
    288 
    289       *((uint16_t *)where + 1) = (uint16_t)((lower_insn & 0xd000)|
    290                                            ((sign ^ (~(tmp >> 23) & 1)) << 13) |
    291                                            ((sign ^ (~(tmp >> 22) & 1)) << 11) |
    292                                            ((tmp >> 1) & 0x7ff));
    293 
    294       if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC)){
    295         printf ("rtl: THM_CALL/JUMP24 %p @ %p in %s\n",
    296                 (void *)*where, where, rtems_rtl_obj_oname (obj));
    297       }
    298 
     357          Elf_Word tramp_addr;
     358          size_t   tramp_size = get_veneer_size(ELF_R_TYPE(rel->r_info));
     359
     360        if (parsing) {
     361          obj->tramp_size += tramp_size;
     362          return true;
     363        }
     364
     365        if (!rtems_rtl_obj_has_ramp_space (obj, tramp_size)) {
     366          rtems_rtl_set_error (EINVAL,
     367                               "%s: THM_CALL/JUMP24: overflow: no tramp memory",
     368                               sect->name);
     369          return false;
     370        }
     371
     372        tramp_addr = ((Elf_Addr) obj->tramp_brk) | (symvalue & 1);
     373        obj->tramp_brk = set_veneer(obj->tramp_brk, symvalue);
     374
     375
     376        tmp = tramp_addr + addend;
     377        tmp = tmp - (Elf_Addr)where;
     378      }
     379
     380      if (!parsing) {
     381        sign = (tmp >> 24) & 1;
     382        *(uint16_t *)where = (uint16_t)((upper_insn & 0xf800) | (sign << 10) |
     383                                        ((tmp >> 12) & 0x3ff));
     384
     385        *((uint16_t *)where + 1) = (uint16_t)((lower_insn & 0xd000)|
     386                                              ((sign ^ (~(tmp >> 23) & 1)) << 13) |
     387                                              ((sign ^ (~(tmp >> 22) & 1)) << 11) |
     388                                              ((tmp >> 1) & 0x7ff));
     389
     390        if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC)){
     391          printf ("rtl: THM_CALL/JUMP24 %p @ %p in %s\n",
     392                  (void *)*where, where, rtems_rtl_obj_oname (obj));
     393        }
     394      }
    299395      break;
    300396
     
    328424                             "THM_JUMP19 relocations",
    329425                             sect->name, (uint32_t) ELF_R_TYPE(rel->r_info));
     426        return true;
    330427        return false;
    331428      }
     
    360457
    361458bool
     459rtems_rtl_elf_relocate_rel_tramp (rtems_rtl_obj*            obj,
     460                                  const Elf_Rel*            rel,
     461                                  const rtems_rtl_obj_sect* sect,
     462                                  const char*               symname,
     463                                  const Elf_Byte            syminfo,
     464                                  const Elf_Word            symvalue)
     465{
     466  return rtems_rtl_elf_relor_rel (obj,
     467                                  rel,
     468                                  sect,
     469                                  symname,
     470                                  syminfo,
     471                                  symvalue,
     472                                  true);
     473}
     474
     475bool
     476rtems_rtl_elf_relocate_rel (rtems_rtl_obj*            obj,
     477                            const Elf_Rel*            rel,
     478                            const rtems_rtl_obj_sect* sect,
     479                            const char*               symname,
     480                            const Elf_Byte            syminfo,
     481                            const Elf_Word            symvalue)
     482{
     483  return rtems_rtl_elf_relor_rel (obj,
     484                                  rel,
     485                                  sect,
     486                                  symname,
     487                                  syminfo,
     488                                  symvalue,
     489                                  false);
     490}
     491
     492bool
    362493rtems_rtl_elf_unwind_parse (const rtems_rtl_obj* obj,
    363494                            const char*          name,
  • cpukit/libdl/rtl-mdreloc-bfin.c

    r4408603 rd8c70ba6  
    3333}
    3434
     35size_t
     36rtems_rtl_elf_relocate_tramp_max_size (void)
     37{
     38  /*
     39   * Disable by returning 0.
     40   */
     41  return 0;
     42}
     43
    3544bool
    36 rtems_rtl_elf_relocate_rela (const rtems_rtl_obj*      obj,
     45rtems_rtl_elf_relocate_rela_tramp (rtems_rtl_obj*            obj,
     46                                   const Elf_Rela*           rela,
     47                                   const rtems_rtl_obj_sect* sect,
     48                                   const char*               symname,
     49                                   const Elf_Byte            syminfo,
     50                                   const Elf_Word            symvalue)
     51{
     52  (void) obj;
     53  (void) rela;
     54  (void) sect;
     55  (void) symname;
     56  (void) syminfo;
     57  (void) symvalue;
     58  return true;
     59}
     60
     61bool
     62rtems_rtl_elf_relocate_rela (rtems_rtl_obj*            obj,
    3763                             const Elf_Rela*           rela,
    3864                             const rtems_rtl_obj_sect* sect,
     
    113139
    114140bool
    115 rtems_rtl_elf_relocate_rel (const rtems_rtl_obj*      obj,
     141rtems_rtl_elf_relocate_rel_tramp (rtems_rtl_obj*            obj,
     142                                  const Elf_Rel*            rel,
     143                                  const rtems_rtl_obj_sect* sect,
     144                                  const char*               symname,
     145                                  const Elf_Byte            syminfo,
     146                                  const Elf_Word            symvalue)
     147{
     148  (void) obj;
     149  (void) rel;
     150  (void) sect;
     151  (void) symname;
     152  (void) syminfo;
     153  (void) symvalue;
     154  rtems_rtl_set_error (EINVAL, "rel type record not supported");
     155  return false;
     156}
     157
     158bool
     159rtems_rtl_elf_relocate_rel (rtems_rtl_obj*            obj,
    116160                            const Elf_Rel*            rel,
    117161                            const rtems_rtl_obj_sect* sect,
     
    120164                            const Elf_Word            symvalue)
    121165{
     166  (void) obj;
     167  (void) rel;
     168  (void) sect;
     169  (void) symname;
     170  (void) syminfo;
     171  (void) symvalue;
    122172  rtems_rtl_set_error (EINVAL, "rel type record not supported");
    123173  return false;
  • cpukit/libdl/rtl-mdreloc-h8300.c

    r4408603 rd8c70ba6  
    2626}
    2727
     28size_t
     29rtems_rtl_elf_relocate_tramp_max_size (void)
     30{
     31  /*
     32   * Disable by returning 0.
     33   */
     34  return 0;
     35}
     36
    2837bool
    29 rtems_rtl_elf_relocate_rela (const rtems_rtl_obj*      obj,
     38rtems_rtl_elf_relocate_rela_tramp (rtems_rtl_obj*            obj,
     39                                   const Elf_Rela*           rela,
     40                                   const rtems_rtl_obj_sect* sect,
     41                                   const char*               symname,
     42                                   const Elf_Byte            syminfo,
     43                                   const Elf_Word            symvalue)
     44{
     45  (void) obj;
     46  (void) rela;
     47  (void) sect;
     48  (void) symname;
     49  (void) syminfo;
     50  (void) symvalue;
     51  return true;
     52}
     53
     54bool
     55rtems_rtl_elf_relocate_rela (rtems_rtl_obj*            obj,
    3056                             const Elf_Rela*           rela,
    3157                             const rtems_rtl_obj_sect* sect,
     
    99125
    100126bool
    101 rtems_rtl_elf_relocate_rel (const rtems_rtl_obj*      obj,
     127rtems_rtl_elf_relocate_rel_tramp (rtems_rtl_obj*           obj,
     128                                  const Elf_Rel*            rel,
     129                                  const rtems_rtl_obj_sect* sect,
     130                                  const char*               symname,
     131                                  const Elf_Byte            syminfo,
     132                                  const Elf_Word            symvalue)
     133{
     134  (void) obj;
     135  (void) rel;
     136  (void) sect;
     137  (void) symname;
     138  (void) syminfo;
     139  (void) symvalue;
     140  rtems_rtl_set_error (EINVAL, "rel type record not supported");
     141  return false;
     142}
     143
     144bool
     145rtems_rtl_elf_relocate_rel (rtems_rtl_obj*            obj,
    102146                            const Elf_Rel*            rel,
    103147                            const rtems_rtl_obj_sect* sect,
     
    106150                            const Elf_Word            symvalue)
    107151{
     152  (void) obj;
     153  (void) rel;
     154  (void) sect;
     155  (void) symname;
     156  (void) syminfo;
     157  (void) symvalue;
    108158  rtems_rtl_set_error (EINVAL, "rel type record not supported");
    109159  return false;
  • cpukit/libdl/rtl-mdreloc-i386.c

    r4408603 rd8c70ba6  
    3232}
    3333
     34size_t
     35rtems_rtl_elf_relocate_tramp_max_size (void)
     36{
     37  /*
     38   * Disable by returning 0.
     39   */
     40  return 0;
     41}
     42
    3443bool
    35 rtems_rtl_elf_relocate_rela (const rtems_rtl_obj*      obj,
     44rtems_rtl_elf_relocate_rela_tramp (rtems_rtl_obj*            obj,
     45                                   const Elf_Rela*           rela,
     46                                   const rtems_rtl_obj_sect* sect,
     47                                   const char*               symname,
     48                                   const Elf_Byte            syminfo,
     49                                   const Elf_Word            symvalue)
     50{
     51  (void) obj;
     52  (void) rela;
     53  (void) sect;
     54  (void) symname;
     55  (void) syminfo;
     56  (void) symvalue;
     57  rtems_rtl_set_error (EINVAL, "rela type record not supported");
     58  return false;
     59}
     60
     61bool
     62rtems_rtl_elf_relocate_rela (rtems_rtl_obj*            obj,
    3663                             const Elf_Rela*           rel,
    3764                             const rtems_rtl_obj_sect* sect,
     
    4067                             const Elf_Word            symvalue)
    4168{
     69  (void) obj;
     70  (void) rela;
     71  (void) sect;
     72  (void) symname;
     73  (void) syminfo;
     74  (void) symvalue;
    4275  rtems_rtl_set_error (EINVAL, "rela type record not supported");
    4376  return false;
     
    4578
    4679bool
    47 rtems_rtl_elf_relocate_rel (const rtems_rtl_obj*      obj,
     80rtems_rtl_elf_relocate_rel_tramp (rtems_rtl_obj*            obj,
     81                                  const Elf_Rel*            rel,
     82                                  const rtems_rtl_obj_sect* sect,
     83                                  const char*               symname,
     84                                  const Elf_Byte            syminfo,
     85                                  const Elf_Word            symvalue)
     86{
     87  (void) obj;
     88  (void) rel;
     89  (void) sect;
     90  (void) symname;
     91  (void) syminfo;
     92  (void) symvalue;
     93  return true;
     94}
     95
     96bool
     97rtems_rtl_elf_relocate_rel (rtems_rtl_obj*            obj,
    4898                            const Elf_Rel*            rel,
    4999                            const rtems_rtl_obj_sect* sect,
  • cpukit/libdl/rtl-mdreloc-lm32.c

    r4408603 rd8c70ba6  
    2626}
    2727
     28size_t
     29rtems_rtl_elf_relocate_tramp_max_size (void)
     30{
     31  /*
     32   * Disable by returning 0.
     33   */
     34  return 0;
     35}
     36
    2837bool
    29 rtems_rtl_elf_relocate_rela (const rtems_rtl_obj*      obj,
     38rtems_rtl_elf_relocate_rela_tramp (rtems_rtl_obj*            obj,
     39                                   const Elf_Rela*           rela,
     40                                   const rtems_rtl_obj_sect* sect,
     41                                   const char*               symname,
     42                                   const Elf_Byte            syminfo,
     43                                   const Elf_Word            symvalue)
     44{
     45  (void) obj;
     46  (void) rela;
     47  (void) sect;
     48  (void) symname;
     49  (void) syminfo;
     50  (void) symvalue;
     51  return true;
     52}
     53
     54bool
     55rtems_rtl_elf_relocate_rela (rtems_rtl_obj*            obj,
    3056                             const Elf_Rela*           rela,
    3157                             const rtems_rtl_obj_sect* sect,
     
    118144
    119145bool
    120 rtems_rtl_elf_relocate_rel (const rtems_rtl_obj*      obj,
     146rtems_rtl_elf_relocate_rel_tramp (rtems_rtl_obj*            obj,
     147                                  const Elf_Rel*            rel,
     148                                  const rtems_rtl_obj_sect* sect,
     149                                  const char*               symname,
     150                                  const Elf_Byte            syminfo,
     151                                  const Elf_Word            symvalue)
     152{
     153  (void) obj;
     154  (void) rela;
     155  (void) sect;
     156  (void) symname;
     157  (void) syminfo;
     158  (void) symvalue;
     159  rtems_rtl_set_error (EINVAL, "rel type record not supported");
     160  return false;
     161}
     162
     163bool
     164rtems_rtl_elf_relocate_rel (rtems_rtl_obj*            obj,
    121165                            const Elf_Rel*            rel,
    122166                            const rtems_rtl_obj_sect* sect,
     
    125169                            const Elf_Word            symvalue)
    126170{
     171  (void) obj;
     172  (void) rela;
     173  (void) sect;
     174  (void) symname;
     175  (void) syminfo;
     176  (void) symvalue;
    127177  rtems_rtl_set_error (EINVAL, "rela type record not supported");
    128178  return false;
  • cpukit/libdl/rtl-mdreloc-m68k.c

    r4408603 rd8c70ba6  
    4646}
    4747
    48 bool
    49 rtems_rtl_elf_relocate_rela (const rtems_rtl_obj*      obj,
     48size_t
     49rtems_rtl_elf_relocate_tramp_max_size (void)
     50{
     51  /*
     52   * Disable by returning 0.
     53   */
     54  return 0;
     55}
     56
     57bool
     58rtems_rtl_elf_relocate_rela_tramp (rtems_rtl_obj*            obj,
     59                                   const Elf_Rela*           rela,
     60                                   const rtems_rtl_obj_sect* sect,
     61                                   const char*               symname,
     62                                   const Elf_Byte            syminfo,
     63                                   const Elf_Word            symvalue)
     64{
     65  (void) obj;
     66  (void) rela;
     67  (void) sect;
     68  (void) symname;
     69  (void) syminfo;
     70  (void) symvalue;
     71  return true;
     72}
     73
     74bool
     75rtems_rtl_elf_relocate_rela (rtems_rtl_obj*            obj,
    5076                             const Elf_Rela*           rela,
    5177                             const rtems_rtl_obj_sect* sect,
     
    146172
    147173bool
    148 rtems_rtl_elf_relocate_rel (const rtems_rtl_obj*      obj,
     174rtems_rtl_elf_relocate_rel_tramp (rtems_rtl_obj*            obj,
     175                                  const Elf_Rel*            rel,
     176                                  const rtems_rtl_obj_sect* sect,
     177                                  const char*               symname,
     178                                  const Elf_Byte            syminfo,
     179                                  const Elf_Word            symvalue)
     180{
     181  (void) obj;
     182  (void) rel;
     183  (void) sect;
     184  (void) symname;
     185  (void) syminfo;
     186  (void) symvalue;
     187  rtems_rtl_set_error (EINVAL, "rel type record not supported");
     188  return false;
     189}
     190
     191bool
     192rtems_rtl_elf_relocate_rel (rtems_rtl_obj*            obj,
    149193                            const Elf_Rel*            rel,
    150194                            const rtems_rtl_obj_sect* sect,
     
    153197                            const Elf_Word            symvalue)
    154198{
     199  (void) obj;
     200  (void) rel;
     201  (void) sect;
     202  (void) symname;
     203  (void) syminfo;
     204  (void) symvalue;
    155205  rtems_rtl_set_error (EINVAL, "rel type record not supported");
    156206  return false;
  • cpukit/libdl/rtl-mdreloc-mips.c

    r4408603 rd8c70ba6  
    2626}
    2727
    28 bool
    29 rtems_rtl_elf_relocate_rela (const rtems_rtl_obj*      obj,
     28size_t
     29rtems_rtl_elf_relocate_tramp_max_size (void)
     30{
     31  /*
     32   * Disable by returning 0.
     33   */
     34  return 0;
     35}
     36
     37bool
     38rtems_rtl_elf_relocate_rela_tramp (rtems_rtl_obj*            obj,
     39                                   const Elf_Rela*           rela,
     40                                   const rtems_rtl_obj_sect* sect,
     41                                   const char*               symname,
     42                                   const Elf_Byte            syminfo,
     43                                   const Elf_Word            symvalue)
     44{
     45  (void) obj;
     46  (void) rela;
     47  (void) sect;
     48  (void) symname;
     49  (void) syminfo;
     50  (void) symvalue;
     51  rtems_rtl_set_error (EINVAL, "rela type record not supported");
     52  return false;
     53}
     54
     55bool
     56rtems_rtl_elf_relocate_rela (rtems_rtl_obj*            obj,
    3057                             const Elf_Rela*           rela,
    3158                             const rtems_rtl_obj_sect* sect,
     
    3461                             const Elf_Word            symvalue)
    3562{
     63  (void) obj;
     64  (void) rela;
     65  (void) sect;
     66  (void) symname;
     67  (void) syminfo;
     68  (void) symvalue;
    3669  rtems_rtl_set_error (EINVAL, "rela type record not supported");
    3770  return false;
     71}
     72
     73bool
     74rtems_rtl_elf_relocate_rel_tramp (rtems_rtl_obj*            obj,
     75                                  const Elf_Rel*            rel,
     76                                  const rtems_rtl_obj_sect* sect,
     77                                  const char*               symname,
     78                                  const Elf_Byte            syminfo,
     79                                  const Elf_Word            symvalue)
     80{
     81  (void) obj;
     82  (void) rel;
     83  (void) sect;
     84  (void) symname;
     85  (void) syminfo;
     86  (void) symvalue;
     87  return true;
    3888}
    3989
     
    4797 */
    4898bool
    49 rtems_rtl_elf_relocate_rel (const rtems_rtl_obj*      obj,
     99rtems_rtl_elf_relocate_rel (rtems_rtl_obj*            obj,
    50100                            const Elf_Rel*            rel,
    51101                            const rtems_rtl_obj_sect* sect,
     
    184234      break;
    185235
    186                 default:
    187      printf ("rtl: reloc unknown: sym = %lu, type = %lu, offset = %p, "
    188              "contents = %p\n",
     236    default:
     237      printf ("rtl: reloc unknown: sym = %lu, type = %lu, offset = %p, "
     238              "contents = %p\n",
    189239              ELF_R_SYM(rel->r_info), (uint32_t) ELF_R_TYPE(rel->r_info),
    190240              (void *)rel->r_offset, (void *)*where);
    191      rtems_rtl_set_error (EINVAL,
    192                           "%s: Unsupported relocation type %ld "
    193                           "in non-PLT relocations",
    194                           sect->name, (uint32_t) ELF_R_TYPE(rel->r_info));
    195      return false;
     241      rtems_rtl_set_error (EINVAL,
     242                           "%s: Unsupported relocation type %ld "
     243                           "in non-PLT relocations",
     244                           sect->name, (uint32_t) ELF_R_TYPE(rel->r_info));
     245      return false;
    196246  }
    197247
  • cpukit/libdl/rtl-mdreloc-moxie.c

    r4408603 rd8c70ba6  
    2727}
    2828
     29size_t
     30rtems_rtl_elf_relocate_tramp_max_size (void)
     31{
     32  /*
     33   * Disable by returning 0.
     34   */
     35  return 0;
     36}
     37
    2938bool
    30 rtems_rtl_elf_relocate_rela (const rtems_rtl_obj*      obj,
     39rtems_rtl_elf_relocate_rela_tramp (rtems_rtl_obj*            obj,
     40                                   const Elf_Rela*           rela,
     41                                   const rtems_rtl_obj_sect* sect,
     42                                   const char*               symname,
     43                                   const Elf_Byte            syminfo,
     44                                   const Elf_Word            symvalue)
     45{
     46  (void) obj;
     47  (void) rela;
     48  (void) sect;
     49  (void) symname;
     50  (void) syminfo;
     51  (void) symvalue;
     52  return true;
     53}
     54
     55bool
     56rtems_rtl_elf_relocate_rela (rtems_rtl_obj*            obj,
    3157                             const Elf_Rela*           rela,
    3258                             const rtems_rtl_obj_sect* sect,
     
    86112
    87113bool
    88 rtems_rtl_elf_relocate_rel (const rtems_rtl_obj*      obj,
     114rtems_rtl_elf_relocate_rel_tramp (rtems_rtl_obj*            obj,
     115                                  const Elf_Rel*            rel,
     116                                  const rtems_rtl_obj_sect* sect,
     117                                  const char*               symname,
     118                                  const Elf_Byte            syminfo,
     119                                  const Elf_Word            symvalue)
     120{
     121  (void) obj;
     122  (void) rel;
     123  (void) sect;
     124  (void) symname;
     125  (void) syminfo;
     126  (void) symvalue;
     127  rtems_rtl_set_error (EINVAL, "rel type record not supported");
     128  return false;
     129}
     130
     131bool
     132rtems_rtl_elf_relocate_rel (rtems_rtl_obj*            obj,
    89133                            const Elf_Rel*            rel,
    90134                            const rtems_rtl_obj_sect* sect,
     
    93137                            const Elf_Word            symvalue)
    94138{
     139  (void) obj;
     140  (void) rel;
     141  (void) sect;
     142  (void) symname;
     143  (void) syminfo;
     144  (void) symvalue;
    95145  rtems_rtl_set_error (EINVAL, "rel type record not supported");
    96146  return false;
  • cpukit/libdl/rtl-mdreloc-powerpc.c

    r4408603 rd8c70ba6  
    3737}
    3838
    39 bool
    40 rtems_rtl_elf_relocate_rela (const rtems_rtl_obj*      obj,
     39size_t
     40rtems_rtl_elf_relocate_tramp_max_size (void)
     41{
     42  /*
     43   * Disable by returning 0.
     44   */
     45  return 0;
     46}
     47
     48bool
     49rtems_rtl_elf_relocate_rela_tramp (rtems_rtl_obj*            obj,
     50                                   const Elf_Rela*           rela,
     51                                   const rtems_rtl_obj_sect* sect,
     52                                   const char*               symname,
     53                                   const Elf_Byte            syminfo,
     54                                   const Elf_Word            symvalue)
     55{
     56  (void) obj;
     57  (void) rela;
     58  (void) sect;
     59  (void) symname;
     60  (void) syminfo;
     61  (void) symvalue;
     62  return true;
     63}
     64
     65bool
     66rtems_rtl_elf_relocate_rela (rtems_rtl_obj*            obj,
    4167                             const Elf_Rela*           rela,
    4268                             const rtems_rtl_obj_sect* sect,
     
    199225
    200226bool
    201 rtems_rtl_elf_relocate_rel (const rtems_rtl_obj*      obj,
     227rtems_rtl_elf_relocate_rel_tramp (rtems_rtl_obj*            obj,
     228                                  const Elf_Rel*            rel,
     229                                  const rtems_rtl_obj_sect* sect,
     230                                  const char*               symname,
     231                                  const Elf_Byte            syminfo,
     232                                  const Elf_Word            symvalue)
     233{
     234  (void) obj;
     235  (void) rel;
     236  (void) sect;
     237  (void) symname;
     238  (void) syminfo;
     239  (void) symvalue;
     240  rtems_rtl_set_error (EINVAL, "rel type record not supported");
     241  return false;
     242}
     243
     244bool
     245rtems_rtl_elf_relocate_rel (rtems_rtl_obj*            obj,
    202246                            const Elf_Rel*            rel,
    203247                            const rtems_rtl_obj_sect* sect,
     
    206250                            const Elf_Word            symvalue)
    207251{
    208   printf ("rtl: rel type record not supported; please report\n");
     252  (void) obj;
     253  (void) rel;
     254  (void) sect;
     255  (void) symname;
     256  (void) syminfo;
     257  (void) symvalue;
     258  rtems_rtl_set_error (EINVAL, "rel type record not supported");
    209259  return false;
    210260}
  • cpukit/libdl/rtl-mdreloc-sparc.c

    r4408603 rd8c70ba6  
    145145}
    146146
    147 bool
    148 rtems_rtl_elf_relocate_rela (const rtems_rtl_obj*      obj,
     147size_t
     148rtems_rtl_elf_relocate_tramp_max_size (void)
     149{
     150  /*
     151   * Disable by returning 0.
     152   */
     153  return 0;
     154}
     155
     156bool
     157rtems_rtl_elf_relocate_rela_tramp (rtems_rtl_obj*            obj,
     158                                   const Elf_Rela*           rela,
     159                                   const rtems_rtl_obj_sect* sect,
     160                                   const char*               symname,
     161                                   const Elf_Byte            syminfo,
     162                                   const Elf_Word            symvalue)
     163{
     164  (void) obj;
     165  (void) rela;
     166  (void) sect;
     167  (void) symname;
     168  (void) syminfo;
     169  (void) symvalue;
     170  return true;
     171}
     172
     173bool
     174rtems_rtl_elf_relocate_rela (rtems_rtl_obj*            obj,
    149175                             const Elf_Rela*           rela,
    150176                             const rtems_rtl_obj_sect* sect,
     
    262288
    263289bool
    264 rtems_rtl_elf_relocate_rel (const rtems_rtl_obj*      obj,
     290rtems_rtl_elf_relocate_rel_tramp (rtems_rtl_obj*            obj,
     291                                  const Elf_Rel*            rel,
     292                                  const rtems_rtl_obj_sect* sect,
     293                                  const char*               symname,
     294                                  const Elf_Byte            syminfo,
     295                                  const Elf_Word            symvalue)
     296{
     297  (void) obj;
     298  (void) rel;
     299  (void) sect;
     300  (void) symname;
     301  (void) syminfo;
     302  (void) symvalue;
     303  rtems_rtl_set_error (EINVAL, "rel type record not supported");
     304  return false;
     305}
     306
     307bool
     308rtems_rtl_elf_relocate_rel (rtems_rtl_obj*            obj,
    265309                            const Elf_Rel*            rel,
    266310                            const rtems_rtl_obj_sect* sect,
     
    269313                            const Elf_Word            symvalue)
    270314{
     315  (void) obj;
     316  (void) rel;
     317  (void) sect;
     318  (void) symname;
     319  (void) syminfo;
     320  (void) symvalue;
    271321  printf ("rtl: rel type record not supported; please report\n");
    272322  return false;
  • cpukit/libdl/rtl-mdreloc-v850.c

    r4408603 rd8c70ba6  
    2727}
    2828
     29size_t
     30rtems_rtl_elf_relocate_tramp_max_size (void)
     31{
     32  /*
     33   * Disable by returning 0.
     34   */
     35  return 0;
     36}
     37
    2938bool
    30 rtems_rtl_elf_relocate_rela (const rtems_rtl_obj*      obj,
     39rtems_rtl_elf_relocate_rela_tramp (rtems_rtl_obj*            obj,
     40                                   const Elf_Rela*           rela,
     41                                   const rtems_rtl_obj_sect* sect,
     42                                   const char*               symname,
     43                                   const Elf_Byte            syminfo,
     44                                   const Elf_Word            symvalue)
     45{
     46  (void) obj;
     47  (void) rela;
     48  (void) sect;
     49  (void) symname;
     50  (void) syminfo;
     51  (void) symvalue;
     52  return true;
     53}
     54
     55bool
     56rtems_rtl_elf_relocate_rela (rtems_rtl_obj*            obj,
    3157                             const Elf_Rela*           rela,
    3258                             const rtems_rtl_obj_sect* sect,
     
    95121
    96122bool
    97 rtems_rtl_elf_relocate_rel (const rtems_rtl_obj*      obj,
     123rtems_rtl_elf_relocate_rel_tramp (rtems_rtl_obj*            obj,
     124                                  const Elf_Rel*            rel,
     125                                  const rtems_rtl_obj_sect* sect,
     126                                  const char*               symname,
     127                                  const Elf_Byte            syminfo,
     128                                  const Elf_Word            symvalue)
     129{
     130  (void) obj;
     131  (void) rel;
     132  (void) sect;
     133  (void) symname;
     134  (void) syminfo;
     135  (void) symvalue;
     136  rtems_rtl_set_error (EINVAL, "rel type record not supported");
     137  return false;
     138}
     139
     140bool
     141rtems_rtl_elf_relocate_rel (rtems_rtl_obj*            obj,
    98142                            const Elf_Rel*            rel,
    99143                            const rtems_rtl_obj_sect* sect,
     
    102146                            const Elf_Word            symvalue)
    103147{
     148  (void) obj;
     149  (void) rel;
     150  (void) sect;
     151  (void) symname;
     152  (void) syminfo;
     153  (void) symvalue;
    104154  rtems_rtl_set_error (EINVAL, "rel type record not supported");
    105155  return false;
  • cpukit/libdl/rtl-obj.c

    r4408603 rd8c70ba6  
    119119  rtems_rtl_obj_erase_dependents (obj);
    120120  rtems_rtl_symbol_obj_erase (obj);
     121  rtems_rtl_obj_erase_trampoline (obj);
    121122  rtems_rtl_obj_free_names (obj);
    122123  if (obj->sec_num != NULL)
     
    558559
    559560bool
     561rtems_rtl_obj_alloc_trampoline (rtems_rtl_obj* obj)
     562{
     563  if (obj->tramp_size == 0)
     564    return true;
     565  obj->trampoline = rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_OBJECT,
     566                                         obj->tramp_size,
     567                                         true);
     568  if (obj->trampoline == NULL)
     569    rtems_rtl_set_error (ENOMEM, "no memory for the trampoline");
     570  obj->tramp_brk = obj->trampoline;
     571  return obj->trampoline != NULL;
     572}
     573
     574void
     575rtems_rtl_obj_erase_trampoline (rtems_rtl_obj* obj)
     576{
     577  rtems_rtl_alloc_del (RTEMS_RTL_ALLOC_OBJECT, obj->trampoline);
     578}
     579
     580bool
    560581rtems_rtl_obj_alloc_dependents (rtems_rtl_obj* obj, size_t dependents)
    561582{
     
    838859                           &sync_ctx);
    839860
    840   if (sync_ctx.end_va != sync_ctx.start_va) {
     861  if (sync_ctx.end_va != sync_ctx.start_va)
     862  {
     863    size_t size = sync_ctx.end_va - sync_ctx.start_va;
    841864    rtems_cache_instruction_sync_after_code_change(sync_ctx.start_va,
    842                               sync_ctx.end_va - sync_ctx.start_va);
     865                                                   size);
     866  }
     867
     868  if (obj->trampoline != NULL)
     869  {
     870    rtems_cache_instruction_sync_after_code_change(obj->trampoline,
     871                                                   obj->tramp_size);
    843872  }
    844873}
  • testsuites/libtests/Makefile.am

    r4408603 rd8c70ba6  
    441441dl05/init.c: dl05-tar.o
    442442dl05.pre: $(dl05_OBJECTS) $(dl05_DEPENDENCIES)
    443         @rm -f dl05.pre
     443        @rm -f dl05.pre dl05-sym.o
    444444        $(AM_V_CXXLD)$(LINK.cc) $(CPU_CFLAGS) $(AM_CFLAGS) $(AM_LDFLAGS) -o $@ $+
    445445dl05-o5.o: dl05/dl-o5.cpp
     
    485485                -DDL06_PRE -c -o $@ $(srcdir)/dl06/init.c
    486486dl06.pre: dl06-pre-init.o dl06/dl06-dl-load.o dl06-pre-tar.o
    487         @rm -f $@
     487        @rm -f $@ dl06-sym.o
    488488        $(AM_V_CCLD)$(LINK.c) $(CPU_CFLAGS) $(AM_CFLAGS) $(AM_LDFLAGS) -o $@ $+ $(LDADD)
    489489dl06-o1.o: dl06/dl06-o1.c Makefile
     
    523523dl07/init.c: dl07-tar.o
    524524dl07.pre: $(dl07_OBJECTS) $(dl07_DEPENDENCIES)
    525         @rm -f dl07.pre
     525        @rm -f dl07.pre dl07-sym.o
    526526        $(AM_V_CCLD)$(LINK.c) $(CPU_CFLAGS) $(AM_CFLAGS) $(AM_LDFLAGS) -o $@ $+
    527527dl07-o1.o: dl07/dl-o1.c Makefile
     
    563563dl08/init.c: dl08-tar.o
    564564dl08.pre: $(dl08_OBJECTS) $(dl08_DEPENDENCIES)
    565         @rm -f dl08.pre
     565        @rm -f dl08.pre dl08-syms.o
    566566        $(AM_V_CCLD)$(LINK.c) $(CPU_CFLAGS) $(AM_CFLAGS) $(AM_LDFLAGS) -o $@ $+
    567567dl08-o1.o: dl08/dl-o1.c Makefile
     
    603603                dl08-o3.o dl08-o4.o dl08-o5.o dl08-o6-123456789-123456789.o \
    604604                dl08.tar dl08-tar.h etc/rtl-libs.conf
     605endif
     606endif
     607
     608if DLTESTS
     609if TEST_dl09
     610lib_tests += dl09
     611lib_screens += dl09/dl09.scn
     612lib_docs += dl09/dl09.doc
     613dl09_SOURCES = dl09/init.c dl09/dl-load.c dl09-tar.c dl09-tar.h
     614dl09_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_dl09) $(support_includes)
     615dl09/init.c: dl09-tar.o
     616dl09.pre: $(dl09_OBJECTS) $(dl09_DEPENDENCIES)
     617        @rm -f dl09.pre dl09-syms.o
     618        $(AM_V_CCLD)$(LINK.c) $(CPU_CFLAGS) $(AM_CFLAGS) $(AM_LDFLAGS) -o $@ $+
     619dl09-o1.o: dl09/dl-o1.c Makefile
     620        $(AM_V_CC)$(COMPILE) -c -o $@ $<
     621dl09-o2.o: dl09/dl-o2.c Makefile
     622        $(AM_V_CC)$(COMPILE) -c -o $@ $<
     623dl09-o3.o: dl09/dl-o3.c Makefile
     624        $(AM_V_CC)$(COMPILE) -c -o $@ $<
     625dl09-o4.o: dl09/dl-o4.c Makefile
     626        $(AM_V_CC)$(COMPILE) -c -o $@ $<
     627dl09-o5.o: dl09/dl-o5.c Makefile
     628        $(AM_V_CC)$(COMPILE) -c -o $@ $<
     629dl09.tar: dl09-o1.o dl09-o2.o dl09-o3.o dl09-o4.o dl09-o5.o
     630        @rm -f $@
     631        $(AM_V_GEN)$(PAX) -w -f $@ $+
     632dl09-tar.c: dl09.tar
     633        $(AM_V_GEN)$(BIN2C) -C $< $@
     634dl09-tar.h: dl09.tar
     635        $(AM_V_GEN)$(BIN2C) -H $< $@
     636dl09-tar.o: dl09-tar.c dl09-tar.h
     637        $(AM_V_CC)$(COMPILE) -c -o $@ $<
     638dl09-sym.o: dl09.pre
     639        $(AM_V_GEN)rtems-syms -e -C $(CC) -c "$(CFLAGS)" -o $@ $<
     640dl09$(EXEEXT):  $(dl09_OBJECTS) $(dl09_DEPENDENCIES) dl09-sym.o
     641        @rm -f $@
     642        $(AM_V_CCLD)$(LINK.c) $(CPU_CFLAGS) $(AM_CFLAGS) $(AM_LDFLAGS) -o $@ $+
     643CLEANFILES += dl09.pre dl09-sym.o dl09-o1.o dl09-o2.o dl09-o3.o dl09-o4.o \
     644                dl09-o5.o dl09.tar dl09-tar.h
    605645endif
    606646endif
  • testsuites/libtests/configure.ac

    r4408603 rd8c70ba6  
    134134RTEMS_TEST_CHECK([dl07])
    135135RTEMS_TEST_CHECK([dl08])
     136RTEMS_TEST_CHECK([dl09])
    136137RTEMS_TEST_CHECK([dumpbuf01])
    137138RTEMS_TEST_CHECK([dup2])
  • testsuites/libtests/dl01/dl-load.c

    r4408603 rd8c70ba6  
    1313#include "dl-load.h"
    1414
     15#include <rtems/rtl/rtl-shell.h>
     16#include <rtems/rtl/rtl-trace.h>
     17
     18#define TEST_TRACE 0
     19#if TEST_TRACE
     20 #define DEBUG_TRACE (RTEMS_RTL_TRACE_DETAIL | \
     21                      RTEMS_RTL_TRACE_WARNING | \
     22                      RTEMS_RTL_TRACE_LOAD | \
     23                      RTEMS_RTL_TRACE_UNLOAD | \
     24                      RTEMS_RTL_TRACE_SYMBOL | \
     25                      RTEMS_RTL_TRACE_RELOC | \
     26                      RTEMS_RTL_TRACE_ALLOCATOR | \
     27                      RTEMS_RTL_TRACE_UNRESOLVED | \
     28                      RTEMS_RTL_TRACE_ARCHIVES | \
     29                      RTEMS_RTL_TRACE_DEPENDENCY)
     30 #define DL_DEBUG_TRACE DEBUG_TRACE /* RTEMS_RTL_TRACE_ALL */
     31 #define DL_RTL_CMDS    1
     32#else
     33 #define DL_DEBUG_TRACE 0
     34 #define DL_RTL_CMDS    0
     35#endif
     36
     37static void dl_load_dump (void)
     38{
     39#if DL_RTL_CMDS
     40  char* list[] = { "rtl", "list", NULL };
     41  char* sym[] = { "rtl", "sym", NULL };
     42  printf ("RTL List:\n");
     43  rtems_rtl_shell_command (2, list);
     44  printf ("RTL Sym:\n");
     45  rtems_rtl_shell_command (2, sym);
     46#endif
     47}
     48
    1549typedef int (*call_t)(int argc, const char* argv[]);
    16 
    1750
    1851static const char* call_1[] = { "Line 1", "Line 2" };
     
    2861  int    unresolved;
    2962  char*  message = "loaded";
     63
     64#if DL_DEBUG_TRACE
     65  rtems_rtl_trace_set_mask (DL_DEBUG_TRACE);
     66#endif
    3067
    3168  printf("load: /dl01-o1.o\n");
     
    4481
    4582  printf ("handle: %p %s\n", handle, message);
     83
     84  dl_load_dump ();
    4685
    4786  call = dlsym (handle, "rtems_main");
  • testsuites/libtests/dl08/dl-load.c

    r4408603 rd8c70ba6  
    88 */
    99
    10 #define ARCHIVE_TRACE (RTEMS_RTL_TRACE_DETAIL | \
    11                        RTEMS_RTL_TRACE_WARNING | \
    12                        RTEMS_RTL_TRACE_LOAD | \
    13                        RTEMS_RTL_TRACE_UNLOAD | \
    14                        RTEMS_RTL_TRACE_SYMBOL | \
    15                        RTEMS_RTL_TRACE_RELOC | \
    16                        RTEMS_RTL_TRACE_ALLOCATOR | \
    17                        RTEMS_RTL_TRACE_UNRESOLVED | \
    18                        RTEMS_RTL_TRACE_ARCHIVES | \
    19                        RTEMS_RTL_TRACE_DEPENDENCY)
    20 #define DL08_DEBUG_TRACE 0 /* RTEMS_RTL_TRACE_ALL */
    21 #define DL08_RTL_CMDS    0
     10#define TEST_TRACE 0
     11#if TEST_TRACE
     12 #define DEBUG_TRACE (RTEMS_RTL_TRACE_DETAIL | \
     13                      RTEMS_RTL_TRACE_WARNING | \
     14                      RTEMS_RTL_TRACE_LOAD | \
     15                      RTEMS_RTL_TRACE_UNLOAD | \
     16                      RTEMS_RTL_TRACE_SYMBOL | \
     17                      RTEMS_RTL_TRACE_RELOC | \
     18                      RTEMS_RTL_TRACE_ALLOCATOR | \
     19                      RTEMS_RTL_TRACE_UNRESOLVED | \
     20                      RTEMS_RTL_TRACE_ARCHIVES | \
     21                      RTEMS_RTL_TRACE_DEPENDENCY)
     22 #define DL_DEBUG_TRACE DEBUG_TRACE /* RTEMS_RTL_TRACE_ALL */
     23 #define DL_RTL_CMDS    1
     24#else
     25 #define DL_DEBUG_TRACE 0
     26 #define DL_RTL_CMDS    0
     27#endif
    2228
    2329#include <dlfcn.h>
     
    3440static void dl_load_dump (void)
    3541{
    36 #if DL08_RTL_CMDS
     42#if DL_RTL_CMDS
    3743  char* list[] = { "rtl", "list", NULL };
    3844  char* sym[] = { "rtl", "sym", NULL };
     
    115121  printf ("Test source (link in strstr): %s\n", dl_localise_file (__FILE__));
    116122
    117 #if DL08_DEBUG_TRACE
    118   rtems_rtl_trace_set_mask (DL08_DEBUG_TRACE);
     123#if DL_DEBUG_TRACE
     124  rtems_rtl_trace_set_mask (DL_DEBUG_TRACE);
    119125#endif
    120126
Note: See TracChangeset for help on using the changeset viewer.