|
| 1 | +diff --git a/llvm/include/llvm/ExecutionEngine/RuntimeDyld.h b/llvm/include/llvm/ExecutionEngine/RuntimeDyld.h |
| 2 | +index 128c9967a596..9dc2f6cf7f98 100644 |
| 3 | +--- a/llvm/include/llvm/ExecutionEngine/RuntimeDyld.h |
| 4 | ++++ b/llvm/include/llvm/ExecutionEngine/RuntimeDyld.h |
| 5 | +@@ -57,6 +57,10 @@ class RuntimeDyldImpl; |
| 6 | + |
| 7 | + class RuntimeDyld { |
| 8 | + public: |
| 9 | ++ |
| 10 | ++ // Should there be a hard failure on a relocation or just soft failure? |
| 11 | ++ static bool ShouldFailOnRelocationErrors; |
| 12 | ++ |
| 13 | + // Change the address associated with a section when resolving relocations. |
| 14 | + // Any relocations already associated with the symbol will be re-resolved. |
| 15 | + void reassignSectionAddress(unsigned SectionID, uint64_t Addr); |
| 16 | +diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp |
| 17 | +index 687fd839805f..2e9e1a2794ac 100644 |
| 18 | +--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp |
| 19 | ++++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp |
| 20 | +@@ -1446,4 +1446,6 @@ void jitLinkForORC( |
| 21 | + std::move(O), std::move(Info)); |
| 22 | + } |
| 23 | + |
| 24 | ++bool RuntimeDyld::ShouldFailOnRelocationErrors = true; |
| 25 | ++ |
| 26 | + } // end namespace llvm |
| 27 | +diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp |
| 28 | +index efe0b9cd61cd..4f29726b2112 100644 |
| 29 | +--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp |
| 30 | ++++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp |
| 31 | +@@ -21,6 +21,7 @@ |
| 32 | + #include "llvm/Object/ObjectFile.h" |
| 33 | + #include "llvm/Support/Endian.h" |
| 34 | + #include "llvm/Support/MemoryBuffer.h" |
| 35 | ++#include "llvm/Support/raw_ostream.h" |
| 36 | + |
| 37 | + using namespace llvm; |
| 38 | + using namespace llvm::object; |
| 39 | +@@ -28,6 +29,17 @@ using namespace llvm::support::endian; |
| 40 | + |
| 41 | + #define DEBUG_TYPE "dyld" |
| 42 | + |
| 43 | ++static void report_reallocation_error(uint32_t ty) { |
| 44 | ++ std::string message; |
| 45 | ++ llvm::raw_string_ostream ss(message); |
| 46 | ++ ss << "Relocation type not implemented yet: " << ty << "!\n"; |
| 47 | ++ if (RuntimeDyld::ShouldFailOnRelocationErrors) { |
| 48 | ++ report_fatal_error(message); |
| 49 | ++ } else { |
| 50 | ++ dbgs() << message; |
| 51 | ++ } |
| 52 | ++} |
| 53 | ++ |
| 54 | + static void or32le(void *P, int32_t V) { write32le(P, read32le(P) | V); } |
| 55 | + |
| 56 | + static void or32AArch64Imm(void *L, uint64_t Imm) { |
| 57 | +@@ -262,7 +274,7 @@ void RuntimeDyldELF::resolveX86_64Relocation(const SectionEntry &Section, |
| 58 | + uint64_t SymOffset) { |
| 59 | + switch (Type) { |
| 60 | + default: |
| 61 | +- report_fatal_error("Relocation type not implemented yet!"); |
| 62 | ++ report_reallocation_error(Type); |
| 63 | + break; |
| 64 | + case ELF::R_X86_64_NONE: |
| 65 | + break; |
| 66 | +@@ -371,7 +383,7 @@ void RuntimeDyldELF::resolveX86Relocation(const SectionEntry &Section, |
| 67 | + default: |
| 68 | + // There are other relocation types, but it appears these are the |
| 69 | + // only ones currently used by the LLVM ELF object writer |
| 70 | +- report_fatal_error("Relocation type not implemented yet!"); |
| 71 | ++ report_reallocation_error(Type); |
| 72 | + break; |
| 73 | + } |
| 74 | + } |
| 75 | +@@ -394,7 +406,7 @@ void RuntimeDyldELF::resolveAArch64Relocation(const SectionEntry &Section, |
| 76 | + |
| 77 | + switch (Type) { |
| 78 | + default: |
| 79 | +- report_fatal_error("Relocation type not implemented yet!"); |
| 80 | ++ report_reallocation_error(Type); |
| 81 | + break; |
| 82 | + case ELF::R_AARCH64_ABS16: { |
| 83 | + uint64_t Result = Value + Addend; |
| 84 | +@@ -779,7 +791,7 @@ void RuntimeDyldELF::resolvePPC32Relocation(const SectionEntry &Section, |
| 85 | + uint8_t *LocalAddress = Section.getAddressWithOffset(Offset); |
| 86 | + switch (Type) { |
| 87 | + default: |
| 88 | +- report_fatal_error("Relocation type not implemented yet!"); |
| 89 | ++ report_reallocation_error(Type); |
| 90 | + break; |
| 91 | + case ELF::R_PPC_ADDR16_LO: |
| 92 | + writeInt16BE(LocalAddress, applyPPClo(Value + Addend)); |
| 93 | +@@ -799,7 +811,7 @@ void RuntimeDyldELF::resolvePPC64Relocation(const SectionEntry &Section, |
| 94 | + uint8_t *LocalAddress = Section.getAddressWithOffset(Offset); |
| 95 | + switch (Type) { |
| 96 | + default: |
| 97 | +- report_fatal_error("Relocation type not implemented yet!"); |
| 98 | ++ report_reallocation_error(Type); |
| 99 | + break; |
| 100 | + case ELF::R_PPC64_ADDR16: |
| 101 | + writeInt16BE(LocalAddress, applyPPClo(Value + Addend)); |
| 102 | +@@ -893,7 +905,7 @@ void RuntimeDyldELF::resolveSystemZRelocation(const SectionEntry &Section, |
| 103 | + uint8_t *LocalAddress = Section.getAddressWithOffset(Offset); |
| 104 | + switch (Type) { |
| 105 | + default: |
| 106 | +- report_fatal_error("Relocation type not implemented yet!"); |
| 107 | ++ report_reallocation_error(Type); |
| 108 | + break; |
| 109 | + case ELF::R_390_PC16DBL: |
| 110 | + case ELF::R_390_PLT16DBL: { |
| 111 | +@@ -948,7 +960,7 @@ void RuntimeDyldELF::resolveBPFRelocation(const SectionEntry &Section, |
| 112 | + |
| 113 | + switch (Type) { |
| 114 | + default: |
| 115 | +- report_fatal_error("Relocation type not implemented yet!"); |
| 116 | ++ report_reallocation_error(Type); |
| 117 | + break; |
| 118 | + case ELF::R_BPF_NONE: |
| 119 | + case ELF::R_BPF_64_64: |
| 120 | +diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h |
| 121 | +index 31892b7466e6..4a2cc70f0e96 100644 |
| 122 | +--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h |
| 123 | ++++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h |
| 124 | +@@ -162,6 +162,7 @@ private: |
| 125 | + bool relocationNeedsStub(const RelocationRef &R) const override; |
| 126 | + |
| 127 | + public: |
| 128 | ++ |
| 129 | + RuntimeDyldELF(RuntimeDyld::MemoryManager &MemMgr, |
| 130 | + JITSymbolResolver &Resolver); |
| 131 | + ~RuntimeDyldELF() override; |
0 commit comments