Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions llvm/lib/ExecutionEngine/JITLink/ELF_loongarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ class ELFLinkGraphBuilder_loongarch : public ELFLinkGraphBuilder<ELFT> {
uint32_t Type = Rel.getType(false);
int64_t Addend = Rel.r_addend;

// ignore
if (Type == ELF::R_LARCH_MARK_LA)
return Error::success();

if (Type == ELF::R_LARCH_RELAX) {
if (BlockToFix.edges_empty())
return make_error<StringError>(
Expand Down
3 changes: 3 additions & 0 deletions llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,9 @@ void RuntimeDyldELF::resolveLoongArch64Relocation(const SectionEntry &Section,
default:
report_fatal_error("Relocation type not implemented yet!");
break;
case ELF::R_LARCH_MARK_LA:
// ignore
break;
case ELF::R_LARCH_32:
support::ulittle32_t::ref{TargetPtr} =
static_cast<uint32_t>(Value + Addend);
Expand Down
4 changes: 3 additions & 1 deletion llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -957,8 +957,10 @@ void LoongArchAsmParser::emitLoadAddressAbs(MCInst &Inst, SMLoc IDLoc,
: Inst.getOperand(2).getExpr();
InstSeq Insts;

// To distinguish between la.abs and %abs_hi20, la.abs will generate
// R_LARCH_MARK_LA and R_LARCH_ABS_HI20 relocations.
Insts.push_back(
LoongArchAsmParser::Inst(LoongArch::LU12I_W, ELF::R_LARCH_ABS_HI20));
LoongArchAsmParser::Inst(LoongArch::LU12I_W, ELF::R_LARCH_MARK_LA));
Insts.push_back(
LoongArchAsmParser::Inst(LoongArch::ORI, ELF::R_LARCH_ABS_LO12));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ static StringRef getLoongArchSpecifierName(uint16_t S) {
return "b16";
case ELF::R_LARCH_B21:
return "b21";
case ELF::R_LARCH_MARK_LA:
case ELF::R_LARCH_ABS_HI20:
return "abs_hi20";
case ELF::R_LARCH_ABS_LO12:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ LoongArchMCCodeEmitter::getExprOpValue(const MCInst &MI, const MCOperand &MO,
case ELF::R_LARCH_B26:
FixupKind = LoongArch::fixup_loongarch_b26;
break;
case ELF::R_LARCH_MARK_LA:
// The R_LARCH_MARCH_LA is used for LoongArch edk2 builds.
Fixups.push_back(
MCFixup::create(0, MCConstantExpr::create(0, Ctx),
FirstLiteralRelocationKind + ELF::R_LARCH_MARK_LA));
[[fallthrough]];
case ELF::R_LARCH_ABS_HI20:
FixupKind = LoongArch::fixup_loongarch_abs_hi20;
break;
Expand Down
1 change: 1 addition & 0 deletions llvm/test/MC/LoongArch/Macros/macros-la.s
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ la.abs $a0, sym_abs
# ABS-NEXT: lu32i.d $a0, %abs64_lo20(sym_abs)
# ABS-NEXT: lu52i.d $a0, $a0, %abs64_hi12(sym_abs)
# ABS-EMPTY:
# RELOC-NEXT: R_LARCH_MARK_LA - 0x0
# RELOC-NEXT: R_LARCH_ABS_HI20 sym_abs 0x0
# RELOC-NEXT: R_LARCH_ABS_LO12 sym_abs 0x0
# RELOC-NEXT: R_LARCH_ABS64_LO20 sym_abs 0x0
Expand Down