[PATCH] D58944: [MC][MachO] Emit an error for emitting relocations of the form -SYM + cst
Francis Visoiu Mistrih via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 6 10:09:57 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL355527: [MC][MachO] Emit an error for emitting relocations of the form -SYM + cst (authored by thegameg, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D58944?vs=189225&id=189532#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58944/new/
https://reviews.llvm.org/D58944
Files:
llvm/trunk/lib/MC/MachObjectWriter.cpp
llvm/trunk/test/MC/MachO/bad-reloc.s
Index: llvm/trunk/test/MC/MachO/bad-reloc.s
===================================================================
--- llvm/trunk/test/MC/MachO/bad-reloc.s
+++ llvm/trunk/test/MC/MachO/bad-reloc.s
@@ -0,0 +1,5 @@
+// RUN: not llvm-mc -triple x86_64-apple-darwin %s -filetype=obj -o - 2>&1 | FileCheck %s
+
+.quad (0 - undef)
+
+// CHECK: error: unsupported relocation expression
Index: llvm/trunk/lib/MC/MachObjectWriter.cpp
===================================================================
--- llvm/trunk/lib/MC/MachObjectWriter.cpp
+++ llvm/trunk/lib/MC/MachObjectWriter.cpp
@@ -13,6 +13,7 @@
#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAsmLayout.h"
#include "llvm/MC/MCAssembler.h"
+#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDirectives.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFixupKindInfo.h"
@@ -448,11 +449,25 @@
assert(W.OS.tell() - Start == Size);
}
+static bool isFixupTargetValid(const MCValue &Target) {
+ // Target is (LHS - RHS + cst).
+ // We don't support the form where LHS is null: -RHS + cst
+ if (!Target.getSymA() && Target.getSymB())
+ return false;
+ return true;
+}
+
void MachObjectWriter::recordRelocation(MCAssembler &Asm,
const MCAsmLayout &Layout,
const MCFragment *Fragment,
const MCFixup &Fixup, MCValue Target,
uint64_t &FixedValue) {
+ if (!isFixupTargetValid(Target)) {
+ Asm.getContext().reportError(Fixup.getLoc(),
+ "unsupported relocation expression");
+ return;
+ }
+
TargetObjectWriter->recordRelocation(this, Asm, Layout, Fragment, Fixup,
Target, FixedValue);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58944.189532.patch
Type: text/x-patch
Size: 1798 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190306/ca2125dc/attachment.bin>
More information about the llvm-commits
mailing list