[LLVMbugs] [Bug 16013] New: RuntimeDyldELF on ARM does not correctly handle repeated relocations (by MCJIT)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed May 15 07:42:13 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16013

            Bug ID: 16013
           Summary: RuntimeDyldELF on ARM does not correctly handle
                    repeated relocations (by MCJIT)
           Product: new-bugs
           Version: trunk
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: david.tweed at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Andrew Kaylor has noted that, unlike some other platforms' relocation routines,
RuntimeDyldELF::resolveARMRelocation is one of the ones which does not
correctly handle repeated relocations on a section, which amongst other
problems causes a segfault with MCJITTest's multiple_functions unittest on ARM
when the correct finalizeObject() call is used. (This appears linked to PR
15357, although that's about avoid repeated relocations to solve the problem
that way.) Quoting Andrew's original email:

[snipped] RuntimeDyldELF's failure to properly handle multiple applications of
relocation information in the case of ARM (and also MIPS, if I recall
correctly).  I think you could verify this by commenting out the call to
Dyld.resolveRelocations in MCJIT::loadObject.  (It really shouldn't be there
anyway.)

I'd prefer to have that test case disabled for ARM rather than have it use the
alternate implementation.  The alternate implementation passes for the wrong
reasons.  Even better would be to have the underlying problem fixed.

The thing that needs to change in RuntimeDyldELF to allow multiple relocations
on ARM is to use Section.ObjAddress to read any values that need to be
retrieved from the original object image.  For instance, the handler for
R_ARM_ABS32 and R_ARM_TARGET1 currently looks like this:

  case ELF::R_ARM_TARGET1 :
  case ELF::R_ARM_ABS32 :
    *TargetPtr += Value;
    break;

(where TargetPtr = Section.Address + Offset).  You can see how that ends up
with a wrong result the second time relocations are applied.

It should be doing something like this instead:

  case ELF::R_ARM_TARGET1 :
  case ELF::R_ARM_ABS32 :
    {
    uint32_t *Placeholder = reinterpret_cast<uint32_t*>(Section.ObjAddress +
Offset);
    *TargetPtr = *Placeholder + Value;
    }
    break;

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130515/3c60c25f/attachment.html>


More information about the llvm-bugs mailing list