[PATCH] D25690: [X86] Correct the number of bits in a fixup

Douglas Katzman via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 17 12:09:32 PDT 2016


dougk created this revision.
dougk added a reviewer: niravd.
dougk added a subscriber: llvm-commits.

The intended behavior on a too-large relative branch is an assembler crash.
We don't need to do the right thing, because the only branch that can't
be relaxed is J[ER]CXZ, and only hand-written code uses that.


https://reviews.llvm.org/D25690

Files:
  lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
  test/MC/X86/reloc-1-byte.s


Index: test/MC/X86/reloc-1-byte.s
===================================================================
--- /dev/null
+++ test/MC/X86/reloc-1-byte.s
@@ -0,0 +1,11 @@
+// RUN: not --crash llvm-mc -triple x86_64-linux-gnu -filetype=obj %s 2>%t.err
+// RUN: FileCheck < %t.err %s
+
+	.code64
+        .text
+        jrcxz 1f
+        .fill 128
+1:
+        ret
+
+// CHECK:   "Value does not fit in the Fixup field"
Index: lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
===================================================================
--- lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
+++ lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
@@ -119,7 +119,7 @@
     // Specifically ignore overflow/underflow as long as the leakage is
     // limited to the lower bits. This is to remain compatible with
     // other assemblers.
-    assert(isIntN(Size * 8 + 1, Value) &&
+    assert(isIntN(Size * 8, Value) &&
            "Value does not fit in the Fixup field");
 
     for (unsigned i = 0; i != Size; ++i)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25690.74884.patch
Type: text/x-patch
Size: 1000 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161017/f54fb3b6/attachment.bin>


More information about the llvm-commits mailing list