From 9743d18ce86564710488a1cd6438f09e95f17b3f Mon Sep 17 00:00:00 2001 From: Dmitri Makarov Date: Sun, 7 Nov 2021 11:35:24 -0800 Subject: [PATCH] [SOL] Revert to R_BPF_64_64 for global data object relocations RBPF doesn't support R_BPF_64_ABS64 and R_BPF_64_64 correctly represents relocation information for global data objects, so we can use them without breaking the correctness of generated object files. --- lld/ELF/Arch/BPF.cpp | 10 ---------- .../lib/Target/BPF/MCTargetDesc/BPFELFObjectWriter.cpp | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/lld/ELF/Arch/BPF.cpp b/lld/ELF/Arch/BPF.cpp index 1d60ff58b96000..fbe5a8c1d7339e 100644 --- a/lld/ELF/Arch/BPF.cpp +++ b/lld/ELF/Arch/BPF.cpp @@ -47,8 +47,6 @@ RelExpr BPF::getRelExpr(RelType type, const Symbol &s, return R_PC; case R_BPF_64_64: return R_ABS; - case R_BPF_64_ABS64: - return R_ADDEND; default: error(getErrorLocation(loc) + "unrecognized reloc " + toString(type)); } @@ -78,14 +76,6 @@ void BPF::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const { write32le(loc + 8 + 4, val >> 32); break; } - case R_BPF_64_ABS64: { - // The relocation type is used for normal 64-bit data. The - // actual to-be-relocated data is stored at r_offset and the - // read/write data bitsize is 64 (8 bytes). The relocation can - // be resolved with the symbol value plus implicit addend. - write64le(loc, val); - break; - } default: error(getErrorLocation(loc) + "unrecognized reloc " + toString(rel.type)); } diff --git a/llvm/lib/Target/BPF/MCTargetDesc/BPFELFObjectWriter.cpp b/llvm/lib/Target/BPF/MCTargetDesc/BPFELFObjectWriter.cpp index 232e5a39bcb7ea..0fff2682e7666f 100644 --- a/llvm/lib/Target/BPF/MCTargetDesc/BPFELFObjectWriter.cpp +++ b/llvm/lib/Target/BPF/MCTargetDesc/BPFELFObjectWriter.cpp @@ -64,7 +64,7 @@ unsigned BPFELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target, // CALL instruction. return ELF::R_BPF_64_32; case FK_Data_8: - return ELF::R_BPF_64_ABS64; + return ELF::R_BPF_64_64; case FK_Data_4: if (const MCSymbolRefExpr *A = Target.getSymA()) { const MCSymbol &Sym = A->getSymbol();