[llvm] r253369 - [RuntimeDyld] Fix resolving R_PPC64_REL24 relocations

Ulrich Weigand via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 17 12:08:31 PST 2015


Author: uweigand
Date: Tue Nov 17 14:08:31 2015
New Revision: 253369

URL: http://llvm.org/viewvc/llvm-project?rev=253369&view=rev
Log:
[RuntimeDyld] Fix resolving R_PPC64_REL24 relocations

When resolving R_PPC64_REL24, code used to check for an address delta
that fits in 24 bits, while the instructions that take this relocation
actually can process address deltas that fit into *26* bits (as those
instructions have a 24 bit field, but implicitly append two zero bits
at the end since all instruction addresses are a multiple of 4).

This means that code would signal overflow once a single object's text
section exceeds 8 MB, while we can actually support up to 32 MB.

Partially fixes PR25540.

Modified:
    llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp

Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp?rev=253369&r1=253368&r2=253369&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp Tue Nov 17 14:08:31 2015
@@ -983,7 +983,7 @@ void RuntimeDyldELF::resolvePPC64Relocat
   case ELF::R_PPC64_REL24: {
     uint64_t FinalAddress = (Section.LoadAddress + Offset);
     int32_t delta = static_cast<int32_t>(Value - FinalAddress + Addend);
-    if (SignExtend32<24>(delta) != delta)
+    if (SignExtend32<26>(delta) != delta)
       llvm_unreachable("Relocation R_PPC64_REL24 overflow");
     // Generates a 'bl <address>' instruction
     writeInt32BE(LocalAddress, 0x48000001 | (delta & 0x03FFFFFC));
@@ -1443,8 +1443,8 @@ relocation_iterator RuntimeDyldELF::proc
         }
         uint8_t *RelocTarget = Sections[Value.SectionID].Address + Value.Addend;
         int32_t delta = static_cast<int32_t>(Target - RelocTarget);
-        // If it is within 24-bits branch range, just set the branch target
-        if (SignExtend32<24>(delta) == delta) {
+        // If it is within 26-bits branch range, just set the branch target
+        if (SignExtend32<26>(delta) == delta) {
           RelocationEntry RE(SectionID, Offset, RelType, Value.Addend);
           if (Value.SymbolName)
             addRelocationForSymbol(RE, Value.SymbolName);




More information about the llvm-commits mailing list