|
11 | 11 | //===----------------------------------------------------------------------===//
|
12 | 12 |
|
13 | 13 | #include "llvm/ExecutionEngine/JITLink/ELF_riscv.h"
|
| 14 | +#include "EHFrameSupportImpl.h" |
14 | 15 | #include "ELFLinkGraphBuilder.h"
|
15 | 16 | #include "JITLinkGeneric.h"
|
16 | 17 | #include "PerGraphGOTAndPLTStubsBuilder.h"
|
17 | 18 | #include "llvm/BinaryFormat/ELF.h"
|
| 19 | +#include "llvm/ExecutionEngine/JITLink/DWARFRecordSectionSplitter.h" |
18 | 20 | #include "llvm/ExecutionEngine/JITLink/JITLink.h"
|
19 | 21 | #include "llvm/ExecutionEngine/JITLink/riscv.h"
|
20 | 22 | #include "llvm/Object/ELF.h"
|
@@ -453,6 +455,18 @@ class ELFJITLinker_riscv : public JITLinker<ELFJITLinker_riscv> {
|
453 | 455 | *(little32_t *)FixupPtr = Word32;
|
454 | 456 | break;
|
455 | 457 | }
|
| 458 | + case Delta64: { |
| 459 | + int64_t Value = E.getTarget().getAddress() + E.getAddend() - FixupAddress; |
| 460 | + *(little64_t *)FixupPtr = Value; |
| 461 | + break; |
| 462 | + } |
| 463 | + case NegDelta32: { |
| 464 | + int64_t Value = FixupAddress - E.getTarget().getAddress() + E.getAddend(); |
| 465 | + if (LLVM_UNLIKELY(!isInRangeForImm(Value, 32))) |
| 466 | + return makeTargetOutOfRangeError(G, B, E); |
| 467 | + *(little32_t *)FixupPtr = Value; |
| 468 | + break; |
| 469 | + } |
456 | 470 | case AlignRelaxable:
|
457 | 471 | // Ignore when the relaxation pass did not run
|
458 | 472 | break;
|
@@ -959,6 +973,13 @@ void link_ELF_riscv(std::unique_ptr<LinkGraph> G,
|
959 | 973 | PassConfiguration Config;
|
960 | 974 | const Triple &TT = G->getTargetTriple();
|
961 | 975 | if (Ctx->shouldAddDefaultTargetPasses(TT)) {
|
| 976 | + // Add eh-frame passses. |
| 977 | + Config.PrePrunePasses.push_back(DWARFRecordSectionSplitter(".eh_frame")); |
| 978 | + Config.PrePrunePasses.push_back( |
| 979 | + EHFrameEdgeFixer(".eh_frame", TT.isRISCV32() ? 4 : 8, riscv::R_RISCV_32, |
| 980 | + riscv::R_RISCV_64, riscv::R_RISCV_32_PCREL, |
| 981 | + riscv::Delta64, riscv::NegDelta32)); |
| 982 | + Config.PrePrunePasses.push_back(EHFrameNullTerminator(".eh_frame")); |
962 | 983 | if (auto MarkLive = Ctx->getMarkLivePass(TT))
|
963 | 984 | Config.PrePrunePasses.push_back(std::move(MarkLive));
|
964 | 985 | else
|
|
0 commit comments