Skip to content

[SOL] re-enable debug info on SBF #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lld/ELF/Arch/BPF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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
Expand All @@ -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));
}
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Target/BPF/BPFTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ BPFTargetMachine::BPFTargetMachine(const Target &T, const Triple &TT,
BPFMCAsmInfo *MAI =
static_cast<BPFMCAsmInfo *>(const_cast<MCAsmInfo *>(AsmInfo.get()));
MAI->setDwarfUsesRelocationsAcrossSections(!Subtarget.getUseDwarfRIS());
bool IsSolana = TT.getArch() == Triple::sbf || FS.contains("solana");
MAI->setSupportsDebugInformation(!IsSolana);
MAI->setSupportsDebugInformation(true);
}

namespace {
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/BPF/MCTargetDesc/BPFELFObjectWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
}

Expand Down