Skip to content

Commit 5b4b870

Browse files
author
Richard Patel
committed
[SOL] support debug-relevant relocs
1 parent 75a0153 commit 5b4b870

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lld/ELF/Arch/BPF.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ RelExpr BPF::getRelExpr(RelType type, const Symbol &s,
4545
switch (type) {
4646
case R_BPF_64_32:
4747
return R_PC;
48+
case R_BPF_64_ABS32:
49+
case R_BPF_64_NODYLD32:
4850
case R_BPF_64_64:
51+
case R_BPF_64_ABS64:
4952
return R_ABS;
5053
default:
5154
error(getErrorLocation(loc) + "unrecognized reloc " + toString(type));
@@ -68,6 +71,12 @@ void BPF::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const {
6871
write32le(loc + 4, ((val - 8) / 8) & 0xFFFFFFFF);
6972
break;
7073
}
74+
case R_BPF_64_ABS32:
75+
case R_BPF_64_NODYLD32: {
76+
// Relocation used by .BTF.ext and DWARF
77+
write32le(loc, val & 0xFFFFFFFF);
78+
break;
79+
}
7180
case R_BPF_64_64: {
7281
// Relocation of a lddw instruction
7382
// 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 {
7685
write32le(loc + 8 + 4, val >> 32);
7786
break;
7887
}
88+
case R_BPF_64_ABS64: {
89+
// Relocation used by DWARF
90+
write64le(loc, val);
91+
break;
92+
}
7993
default:
8094
error(getErrorLocation(loc) + "unrecognized reloc " + toString(rel.type));
8195
}

llvm/lib/Target/BPF/MCTargetDesc/BPFELFObjectWriter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ unsigned BPFELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
6464
// CALL instruction.
6565
return ELF::R_BPF_64_32;
6666
case FK_Data_8:
67-
return isSolana ? ELF::R_BPF_64_64 : ELF::R_BPF_64_ABS64;
67+
return ELF::R_BPF_64_ABS64;
6868
case FK_Data_4:
6969
if (const MCSymbolRefExpr *A = Target.getSymA()) {
7070
const MCSymbol &Sym = A->getSymbol();
@@ -94,7 +94,7 @@ unsigned BPFELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
9494
}
9595
}
9696
}
97-
return isSolana ? ELF::R_BPF_64_32 : ELF::R_BPF_64_ABS32;
97+
return ELF::R_BPF_64_ABS32;
9898
}
9999
}
100100

0 commit comments

Comments
 (0)