[PATCH] D71536: [RISCV] Don't crash on unsupported relocations
Luís Marques via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 19 09:23:45 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rGec4f06a77ded: [RISCV] Don't crash on unsupported relocations (authored by luismarques).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71536/new/
https://reviews.llvm.org/D71536
Files:
llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFObjectWriter.cpp
llvm/test/MC/RISCV/fixups-invalid.s
Index: llvm/test/MC/RISCV/fixups-invalid.s
===================================================================
--- /dev/null
+++ llvm/test/MC/RISCV/fixups-invalid.s
@@ -0,0 +1,7 @@
+# RUN: not llvm-mc -filetype=obj %s -triple=riscv32 -o /dev/null 2>&1 \
+# RUN: | FileCheck %s
+# RUN: not llvm-mc -filetype=obj %s -triple=riscv64 -o /dev/null 2>&1 \
+# RUN: | FileCheck %s
+
+.byte foo # CHECK: [[@LINE]]:7: error: 1-byte data relocations not supported
+.2byte foo # CHECK: [[@LINE]]:8: error: 2-byte data relocations not supported
Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFObjectWriter.cpp
===================================================================
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFObjectWriter.cpp
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFObjectWriter.cpp
@@ -9,6 +9,7 @@
#include "MCTargetDesc/RISCVFixupKinds.h"
#include "MCTargetDesc/RISCVMCExpr.h"
#include "MCTargetDesc/RISCVMCTargetDesc.h"
+#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCELFObjectWriter.h"
#include "llvm/MC/MCFixup.h"
#include "llvm/MC/MCObjectWriter.h"
@@ -54,7 +55,8 @@
if (IsPCRel) {
switch (Kind) {
default:
- llvm_unreachable("invalid fixup kind!");
+ Ctx.reportError(Fixup.getLoc(), "Unsupported relocation type");
+ return ELF::R_RISCV_NONE;
case FK_Data_4:
case FK_PCRel_4:
return ELF::R_RISCV_32_PCREL;
@@ -87,7 +89,14 @@
switch (Kind) {
default:
- llvm_unreachable("invalid fixup kind!");
+ Ctx.reportError(Fixup.getLoc(), "Unsupported relocation type");
+ return ELF::R_RISCV_NONE;
+ case FK_Data_1:
+ Ctx.reportError(Fixup.getLoc(), "1-byte data relocations not supported");
+ return ELF::R_RISCV_NONE;
+ case FK_Data_2:
+ Ctx.reportError(Fixup.getLoc(), "2-byte data relocations not supported");
+ return ELF::R_RISCV_NONE;
case FK_Data_4:
if (Expr->getKind() == MCExpr::Target &&
cast<RISCVMCExpr>(Expr)->getKind() == RISCVMCExpr::VK_RISCV_32_PCREL)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71536.234741.patch
Type: text/x-patch
Size: 1991 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191219/87ee4f05/attachment.bin>
More information about the llvm-commits
mailing list