[PATCH] D28516: [ELF] - Explicitly list supported relocations for x86 target.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 11 00:40:51 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL291658: [ELF] - Explicitly list supported relocations for x86 target. (authored by grimar).

Changed prior to commit:
  https://reviews.llvm.org/D28516?vs=83807&id=83925#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28516

Files:
  lld/trunk/ELF/Target.cpp
  lld/trunk/test/ELF/Inputs/unknown-reloc.s
  lld/trunk/test/ELF/unknown-reloc.s


Index: lld/trunk/ELF/Target.cpp
===================================================================
--- lld/trunk/ELF/Target.cpp
+++ lld/trunk/ELF/Target.cpp
@@ -356,7 +356,9 @@
 
 RelExpr X86TargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S) const {
   switch (Type) {
-  default:
+  case R_386_16:
+  case R_386_32:
+  case R_386_TLS_LDO_32:
     return R_ABS;
   case R_386_TLS_GD:
     return R_TLSGD;
@@ -381,6 +383,10 @@
     return R_TLS;
   case R_386_TLS_LE_32:
     return R_NEG_TLS;
+  default:
+    error("do not know how to handle relocation " + toString(Type) + " (" +
+          Twine(Type) + ")");
+    return R_HINT;
   }
 }
 
Index: lld/trunk/test/ELF/Inputs/unknown-reloc.s
===================================================================
--- lld/trunk/test/ELF/Inputs/unknown-reloc.s
+++ lld/trunk/test/ELF/Inputs/unknown-reloc.s
@@ -0,0 +1,2 @@
+.global und
+und:
Index: lld/trunk/test/ELF/unknown-reloc.s
===================================================================
--- lld/trunk/test/ELF/unknown-reloc.s
+++ lld/trunk/test/ELF/unknown-reloc.s
@@ -0,0 +1,14 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=i386-pc-linux-gnu %s -o %t1.o
+# RUN: llvm-mc -filetype=obj -triple=i386-pc-linux-gnu %S/Inputs/unknown-reloc.s -o %t2.o
+# RUN: not ld.lld %t1.o %t2.o -o %t.out 2>&1 | FileCheck %s
+
+# CHECK: do not know how to handle relocation R_386_PC8 (23)
+# CHECK: do not know how to handle relocation R_386_8 (22)
+
+.text
+.global foo
+foo:
+
+.byte und-foo
+.byte foo


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28516.83925.patch
Type: text/x-patch
Size: 1518 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170111/ceedbe2d/attachment.bin>


More information about the llvm-commits mailing list