Ticket #2802: libdl-sparc-R_SPARC_32-missaligned.patch

File libdl-sparc-R_SPARC_32-missaligned.patch, 1.2 KB (added by Chris Johns, on 11/11/16 at 06:09:35)

Miss-aligned R_SPARC_32 offset work around.

  • cpukit/libdl/rtl-mdreloc-sparc.c

    diff --git a/cpukit/libdl/rtl-mdreloc-sparc.c b/cpukit/libdl/rtl-mdreloc-sparc.c
    index a8bf5e1..b5c6b2c 100644
    a b rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj, 
    218218  value >>= RELOC_VALUE_RIGHTSHIFT (type);
    219219  value &= mask;
    220220
    221   if (RELOC_UNALIGNED(type)) {
     221  if (RELOC_UNALIGNED(type) || ((((intptr_t) where) & 3) != 0)) {
    222222    /* Handle unaligned relocations. */
    223223    Elf_Addr tmp = 0;
    224224    char *ptr = (char *)where;
    rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj, 
    235235    for (i=0; i<size; i++)
    236236      ptr[i] = ((tmp >> (8*i)) & 0xff);
    237237
     238    if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC)) {
     239      ptr = (char*)&value;
     240      for (i=0; i<size; i++)
     241        ptr[i] = ((tmp >> (8*i)) & 0xff);
     242    }
     243
    238244  } else {
    239245    *where &= ~mask;
    240246    *where |= value;
     247    if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC))
     248      value = *where;
    241249  }
    242250
    243251  if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC))
    244252    printf ("rtl: %s %p @ %p in %s\n",
    245             reloc_names[type], (void *)*where, where, rtems_rtl_obj_oname (obj));
    246 
     253            reloc_names[type], (void *)value, where, rtems_rtl_obj_oname (obj));
    247254
    248255  return true;
    249256}