diff --git a/lld/ELF/Arch/BPF.cpp b/lld/ELF/Arch/BPF.cpp index fbe5a8c1d7339..6ec09b0d296a0 100644 --- a/lld/ELF/Arch/BPF.cpp +++ b/lld/ELF/Arch/BPF.cpp @@ -45,7 +45,10 @@ RelExpr BPF::getRelExpr(RelType type, const Symbol &s, switch (type) { case R_BPF_64_32: return R_PC; + case R_BPF_64_ABS32: + case R_BPF_64_NODYLD32: case R_BPF_64_64: + case R_BPF_64_ABS64: return R_ABS; default: error(getErrorLocation(loc) + "unrecognized reloc " + toString(type)); @@ -68,6 +71,12 @@ void BPF::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const { write32le(loc + 4, ((val - 8) / 8) & 0xFFFFFFFF); break; } + case R_BPF_64_ABS32: + case R_BPF_64_NODYLD32: { + // Relocation used by .BTF.ext and DWARF + write32le(loc, val & 0xFFFFFFFF); + break; + } case R_BPF_64_64: { // Relocation of a lddw instruction // 64 bit address is divided into the imm of this and the following @@ -76,6 +85,11 @@ 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: { + // Relocation used by DWARF + write64le(loc, val); + break; + } default: error(getErrorLocation(loc) + "unrecognized reloc " + toString(rel.type)); } diff --git a/llvm/lib/Target/BPF/BPFTargetMachine.cpp b/llvm/lib/Target/BPF/BPFTargetMachine.cpp index 08d6b89ffa036..024ef6aa2321c 100644 --- a/llvm/lib/Target/BPF/BPFTargetMachine.cpp +++ b/llvm/lib/Target/BPF/BPFTargetMachine.cpp @@ -83,8 +83,7 @@ BPFTargetMachine::BPFTargetMachine(const Target &T, const Triple &TT, BPFMCAsmInfo *MAI = static_cast(const_cast(AsmInfo.get())); MAI->setDwarfUsesRelocationsAcrossSections(!Subtarget.getUseDwarfRIS()); - bool IsSolana = TT.getArch() == Triple::sbf || FS.contains("solana"); - MAI->setSupportsDebugInformation(!IsSolana); + MAI->setSupportsDebugInformation(true); } namespace { diff --git a/llvm/lib/Target/BPF/MCTargetDesc/BPFELFObjectWriter.cpp b/llvm/lib/Target/BPF/MCTargetDesc/BPFELFObjectWriter.cpp index 50899f2b9e2fa..232e5a39bcb7e 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 isSolana ? ELF::R_BPF_64_64 : ELF::R_BPF_64_ABS64; + return ELF::R_BPF_64_ABS64; case FK_Data_4: if (const MCSymbolRefExpr *A = Target.getSymA()) { const MCSymbol &Sym = A->getSymbol(); @@ -94,7 +94,7 @@ unsigned BPFELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target, } } } - return isSolana ? ELF::R_BPF_64_32 : ELF::R_BPF_64_ABS32; + return ELF::R_BPF_64_ABS32; } }