[mips] Resolve relocation for the stubs in MCJIT when load address is known
authorPetar Jovanovic <petar.jovanovic@imgtec.com>
Tue, 19 Nov 2013 21:56:00 +0000 (21:56 +0000)
committerPetar Jovanovic <petar.jovanovic@imgtec.com>
Tue, 19 Nov 2013 21:56:00 +0000 (21:56 +0000)
Instead of processing relocation for branch to stubs right away, emit a
modified relocation and add it to queue to be resolved later when final load
address is known.
This resolves seven MIPS MCJIT issues that were caused by missing relocation
fixups at the end.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195157 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
test/ExecutionEngine/MCJIT/remote/cross-module-a.ll
test/ExecutionEngine/MCJIT/remote/multi-module-a.ll
test/ExecutionEngine/MCJIT/remote/simpletest-remote.ll
test/ExecutionEngine/MCJIT/remote/test-common-symbols-remote.ll
test/ExecutionEngine/MCJIT/remote/test-data-align-remote.ll
test/ExecutionEngine/MCJIT/remote/test-fp-no-external-funcs-remote.ll
test/ExecutionEngine/MCJIT/remote/test-global-init-nonzero-remote.ll

index fa14c8c6aba81a47ba6ddf009a796d3bd11c5e2a..f2c69fc99cecd27c17151d5363e51659306d621a 100644 (file)
@@ -1031,8 +1031,8 @@ void RuntimeDyldELF::processRelocationRef(unsigned SectionID,
     //  Look up for existing stub.
     StubMap::const_iterator i = Stubs.find(Value);
     if (i != Stubs.end()) {
-      resolveRelocation(Section, Offset,
-                        (uint64_t)Section.Address + i->second, RelType, 0);
+      RelocationEntry RE(SectionID, Offset, RelType, i->second);
+      addRelocationForSection(RE, SectionID);
       DEBUG(dbgs() << " Stub function found\n");
     } else {
       // Create a new stub function.
@@ -1057,9 +1057,8 @@ void RuntimeDyldELF::processRelocationRef(unsigned SectionID,
         addRelocationForSection(RELo, Value.SectionID);
       }
 
-      resolveRelocation(Section, Offset,
-                        (uint64_t)Section.Address + Section.StubOffset,
-                        RelType, 0);
+      RelocationEntry RE(SectionID, Offset, RelType, Section.StubOffset);
+      addRelocationForSection(RE, SectionID);
       Section.StubOffset += getMaxStubSize();
     }
   } else if (Arch == Triple::ppc64 || Arch == Triple::ppc64le) {
index 97bb96af5b7408af8556e5752ed767c1cf928e54..094d362262c5c5fd3d5ebc915405fbaabacca95a 100644 (file)
@@ -1,7 +1,5 @@
 ; RUN: %lli_mcjit -extra-module=%p/Inputs/cross-module-b.ll -disable-lazy-compilation=true -remote-mcjit -mcjit-remote-process=lli-child-target %s > /dev/null
 
-; XFAIL: mips
-
 declare i32 @FB()
 
 define i32 @FA() {
index 8fbd3451ee5e355fbf2cb939564e718ce7ba5468..91d0387376ca6b1780e656a3ebaf640da2419c50 100644 (file)
@@ -1,7 +1,5 @@
 ; RUN: %lli_mcjit -extra-module=%p/Inputs/multi-module-b.ll -extra-module=%p/Inputs/multi-module-c.ll -disable-lazy-compilation=true -remote-mcjit -mcjit-remote-process=lli-child-target %s > /dev/null
 
-; XFAIL: mips
-
 declare i32 @FB()
 
 define i32 @main() {
index 51c6d2584aa6eb046ce4119a4af2e3d8dedb9aa0..d10a4117a0ddaaac95d991e38c15c17dbb771b3f 100644 (file)
@@ -1,7 +1,5 @@
 ; RUN: %lli_mcjit -remote-mcjit -mcjit-remote-process=lli-child-target %s > /dev/null
 
-; XFAIL: mips
-
 define i32 @bar() {
        ret i32 0
 }
index ea4acc5b2f05ea08d7b873151c6f1d140ad26c5f..63280895a9a3f264736e6188f9fe1c0bd863b0eb 100644 (file)
@@ -1,7 +1,5 @@
 ; RUN: %lli_mcjit -remote-mcjit -O0 -disable-lazy-compilation=false -mcjit-remote-process=lli-child-target %s
 
-; XFAIL: mips
-
 ; The intention of this test is to verify that symbols mapped to COMMON in ELF
 ; work as expected.
 ;
index 297925498fb46364e2c535a68e76ac11aa6e3711..6b2b97bc2d7e4e310dc89decba176b5f464b6602 100644 (file)
@@ -1,7 +1,5 @@
 ; RUN:  %lli_mcjit -remote-mcjit -O0 -mcjit-remote-process=lli-child-target %s
 
-; XFAIL: mips
-
 ; Check that a variable is always aligned as specified.
 
 @var = global i32 0, align 32
index 6bad7a2584196223cabc13299c7fe8be91e8a1cb..a8a93a8dc3bf3debe7a0c28e969c278228af6b79 100644 (file)
@@ -1,7 +1,5 @@
 ; RUN: %lli_mcjit -remote-mcjit -mcjit-remote-process=lli-child-target %s > /dev/null
 
-; XFAIL: mips
-
 define double @test(double* %DP, double %Arg) {
        %D = load double* %DP           ; <double> [#uses=1]
        %V = fadd double %D, 1.000000e+00               ; <double> [#uses=2]
index cdb577938c8605a26a865be5f52fb6a2c8fddb8f..4181fb08842c9e36a98145c1f9ae33bc27045c6b 100644 (file)
@@ -1,7 +1,5 @@
 ; RUN: %lli_mcjit -remote-mcjit -mcjit-remote-process=lli-child-target %s > /dev/null
 
-; XFAIL: mips
-
 @count = global i32 1, align 4
 
 define i32 @main() nounwind uwtable {