[PATCH] D71820: [lld][RISCV] Print error when encountering R_RISCV_ALIGN

James Clarke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 14 03:30:59 PST 2020


jrtc27 updated this revision to Diff 237914.
jrtc27 added a comment.

Rebased and addressed review comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71820/new/

https://reviews.llvm.org/D71820

Files:
  lld/ELF/Arch/RISCV.cpp
  lld/test/ELF/riscv-reloc-align.s


Index: lld/test/ELF/riscv-reloc-align.s
===================================================================
--- /dev/null
+++ lld/test/ELF/riscv-reloc-align.s
@@ -0,0 +1,12 @@
+# REQUIRES: riscv
+
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+relax %s -o %t.o
+# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
+
+# CHECK: relocation R_RISCV_ALIGN requires unimplemented linker relaxation
+
+.global _start
+_start:
+    nop
+    .balign 8
+    nop
Index: lld/ELF/Arch/RISCV.cpp
===================================================================
--- lld/ELF/Arch/RISCV.cpp
+++ lld/ELF/Arch/RISCV.cpp
@@ -236,9 +236,15 @@
   case R_RISCV_TPREL_LO12_S:
     return R_TLS;
   case R_RISCV_RELAX:
-  case R_RISCV_ALIGN:
   case R_RISCV_TPREL_ADD:
     return R_NONE;
+  case R_RISCV_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_RISCV_ALIGN requires "
+                "unimplemented linker relaxation; recompile with -mno-relax");
+    return R_NONE;
   default:
     error(getErrorLocation(loc) + "unknown relocation (" + Twine(type) +
           ") against symbol " + toString(s));
@@ -431,7 +437,6 @@
     write64le(loc, val - dtpOffset);
     break;
 
-  case R_RISCV_ALIGN:
   case R_RISCV_RELAX:
     return; // Ignored (for now)
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71820.237914.patch
Type: text/x-patch
Size: 1459 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200114/76ab3e56/attachment.bin>


More information about the llvm-commits mailing list