[PATCH] D54776: Produce an error on non-encodable offsets for darwin ARM scattered relocations.

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 29 14:01:30 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL347922: Produce an error on non-encodable offsets for darwin ARM scattered relocations. (authored by JDevlieghere, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54776?vs=174848&id=175953#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D54776

Files:
  llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp
  llvm/trunk/test/MC/MachO/ARM/bad-darwin-ARM-offset-scattered.s


Index: llvm/trunk/test/MC/MachO/ARM/bad-darwin-ARM-offset-scattered.s
===================================================================
--- llvm/trunk/test/MC/MachO/ARM/bad-darwin-ARM-offset-scattered.s
+++ llvm/trunk/test/MC/MachO/ARM/bad-darwin-ARM-offset-scattered.s
@@ -0,0 +1,15 @@
+@ RUN: not llvm-mc -n -triple armv7-apple-darwin10 %s -filetype=obj -o - 2> %t.err > %t
+@ RUN: FileCheck --check-prefix=CHECK-ERROR < %t.err %s
+
+.text
+.space 0x1029eb8
+
+fn:
+    movw  r0, :lower16:(fn2-L1)
+    andeq r0, r0, r0
+L1:
+    andeq r0, r0, r0
+
+fn2:
+
+@ CHECK-ERROR: error: can not encode offset '0x1029EB8' in resulting scattered relocation.
Index: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp
===================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp
@@ -22,6 +22,8 @@
 #include "llvm/MC/MCSection.h"
 #include "llvm/MC/MCValue.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/ScopedPrinter.h"
+
 using namespace llvm;
 
 namespace {
@@ -144,6 +146,15 @@
                                  MCValue Target,
                                  uint64_t &FixedValue) {
   uint32_t FixupOffset = Layout.getFragmentOffset(Fragment)+Fixup.getOffset();
+
+  if (FixupOffset & 0xff000000) {
+    Asm.getContext().reportError(Fixup.getLoc(),
+                                 "can not encode offset '0x" +
+                                     to_hexString(FixupOffset) +
+                                     "' in resulting scattered relocation.");
+    return;
+  }
+
   unsigned IsPCRel = Writer->isFixupKindPCRel(Asm, Fixup.getKind());
   unsigned Type = MachO::ARM_RELOC_HALF;
 
@@ -250,6 +261,15 @@
                                                     unsigned Log2Size,
                                                     uint64_t &FixedValue) {
   uint32_t FixupOffset = Layout.getFragmentOffset(Fragment)+Fixup.getOffset();
+
+  if (FixupOffset & 0xff000000) {
+    Asm.getContext().reportError(Fixup.getLoc(),
+                                 "can not encode offset '0x" +
+                                     to_hexString(FixupOffset) +
+                                     "' in resulting scattered relocation.");
+    return;
+  }
+
   unsigned IsPCRel = Writer->isFixupKindPCRel(Asm, Fixup.getKind());
 
   // See <reloc.h>.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54776.175953.patch
Type: text/x-patch
Size: 2425 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181129/f5f71842/attachment-0001.bin>


More information about the llvm-commits mailing list