[PATCH] D45051: [ELF] - Relax checks for R_386_8/R_386_16 relocations.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 30 01:57:12 PDT 2018


grimar updated this revision to Diff 140395.
grimar added a comment.

- Using checkIntUInt.


https://reviews.llvm.org/D45051

Files:
  ELF/Arch/X86.cpp
  test/ELF/i386-reloc-16-large-addend.s
  test/ELF/i386-reloc-16.s
  test/ELF/i386-reloc-8-large-addend.s
  test/ELF/i386-reloc-8.s


Index: test/ELF/i386-reloc-8.s
===================================================================
--- test/ELF/i386-reloc-8.s
+++ test/ELF/i386-reloc-8.s
@@ -10,6 +10,6 @@
 // CHECK-NEXT:   1000 ff
 
 // RUN: not ld.lld -shared %t %t2 -o %t4 2>&1 | FileCheck --check-prefix=ERROR %s
-// ERROR: relocation R_386_8 out of range: 256 is not in [0, 255]
+// ERROR: relocation R_386_8 out of range: 256 is not in [-128, 127]
 
 .byte foo
Index: test/ELF/i386-reloc-8-large-addend.s
===================================================================
--- test/ELF/i386-reloc-8-large-addend.s
+++ test/ELF/i386-reloc-8-large-addend.s
@@ -0,0 +1,12 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %s -o %t
+# RUN: ld.lld -Ttext 0x7c %t -o %t2
+# RUN: llvm-objdump -s %t2 | FileCheck %s
+
+# CHECK:       Contents of section .text:
+# CHECK-NEXT:  007c b4ff
+
+.code16
+.global _start
+_start:
+ movb $_start+0x83,%ah
Index: test/ELF/i386-reloc-16.s
===================================================================
--- test/ELF/i386-reloc-16.s
+++ test/ELF/i386-reloc-16.s
@@ -10,6 +10,6 @@
 // CHECK-NEXT:   1000 42
 
 // RUN: not ld.lld -shared %t %t2 -o %t4 2>&1 | FileCheck --check-prefix=ERROR %s
-// ERROR: relocation R_386_16 out of range: 65536 is not in [0, 65535]
+// ERROR: relocation R_386_16 out of range: 65536 is not in [-32768, 32767]
 
 .short foo
Index: test/ELF/i386-reloc-16-large-addend.s
===================================================================
--- test/ELF/i386-reloc-16-large-addend.s
+++ test/ELF/i386-reloc-16-large-addend.s
@@ -0,0 +1,12 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %s -o %t
+# RUN: ld.lld -Ttext 0x7c00 %t -o %t2
+# RUN: llvm-objdump -s %t2 | FileCheck %s
+
+# CHECK:       Contents of section .text:
+# CHECK-NEXT:  7c00 b800ff
+
+.code16
+.global _start
+_start:
+ movw $_start+0x8300,%ax
Index: ELF/Arch/X86.cpp
===================================================================
--- ELF/Arch/X86.cpp
+++ ELF/Arch/X86.cpp
@@ -255,15 +255,15 @@
     // R_386_{PC,}{8,16} are not part of the i386 psABI, but they are
     // being used for some 16-bit programs such as boot loaders, so
     // we want to support them.
-    checkUInt(Loc, Val, 8, Type);
+    checkIntUInt(Loc, Val, 8, Type);
     *Loc = Val;
     break;
   case R_386_PC8:
     checkInt(Loc, Val, 8, Type);
     *Loc = Val;
     break;
   case R_386_16:
-    checkUInt(Loc, Val, 16, Type);
+    checkIntUInt(Loc, Val, 16, Type);
     write16le(Loc, Val);
     break;
   case R_386_PC16:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45051.140395.patch
Type: text/x-patch
Size: 2557 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180330/60cda102/attachment.bin>


More information about the llvm-commits mailing list