Skip to content
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

[lld][LoongArch] Print error when encountering R_LARCH_ALIGN #67424

Closed
wants to merge 1 commit into from
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
8 changes: 8 additions & 0 deletions lld/ELF/Arch/LoongArch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,14 @@ RelExpr LoongArch::getRelExpr(const RelType type, const Symbol &s,
case R_LARCH_RELAX:
// LoongArch linker relaxation is not implemented yet.
return R_NONE;
case R_LARCH_ALIGN:
// Not just a hint; always padded to the worst-case number of NOPs, so may
// not currently be aligned, and without linker relaxation support we can't
// delete NOPs to realign.
errorOrWarn(getErrorLocation(loc) +
"relocation R_LARCH_ALIGN requires "
"unimplemented linker relaxation; recompile with -mno-relax");
return R_NONE;

// Other known relocs that are explicitly unimplemented:
//
Expand Down
15 changes: 15 additions & 0 deletions lld/test/ELF/loongarch-reloc-align.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# REQUIRES: loongarch

# RUN: llvm-mc --filetype=obj --triple=loongarch64 %s -o %t.o
# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s

# CHECK: relocation R_LARCH_ALIGN requires unimplemented linker relaxation

.global _start
_start:
addi.d $t0, $t0, 1
1:
nop
.reloc 1b, R_LARCH_ALIGN, 12
nop
nop