[lld] r259435 - ELF: Do not call fatal() if relocation contraints are not satisfied.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 1 15:28:21 PST 2016


Author: ruiu
Date: Mon Feb  1 17:28:21 2016
New Revision: 259435

URL: http://llvm.org/viewvc/llvm-project?rev=259435&view=rev
Log:
ELF: Do not call fatal() if relocation contraints are not satisfied.

http://reviews.llvm.org/D16648

Added:
    lld/trunk/test/ELF/x86-64-reloc-error.s
      - copied, changed from r259431, lld/trunk/test/ELF/x86-64-reloc-32-error.s
Removed:
    lld/trunk/test/ELF/x86-64-reloc-32-error.s
    lld/trunk/test/ELF/x86-64-reloc-32S-error.s
Modified:
    lld/trunk/ELF/Target.cpp
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=259435&r1=259434&r2=259435&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Mon Feb  1 17:28:21 2016
@@ -46,28 +46,28 @@ template <unsigned N> static void checkI
   if (isInt<N>(V))
     return;
   StringRef S = getELFRelocationTypeName(Config->EMachine, Type);
-  fatal("Relocation " + S + " out of range");
+  error("Relocation " + S + " out of range");
 }
 
 template <unsigned N> static void checkUInt(uint64_t V, uint32_t Type) {
   if (isUInt<N>(V))
     return;
   StringRef S = getELFRelocationTypeName(Config->EMachine, Type);
-  fatal("Relocation " + S + " out of range");
+  error("Relocation " + S + " out of range");
 }
 
 template <unsigned N> static void checkIntUInt(uint64_t V, uint32_t Type) {
   if (isInt<N>(V) || isUInt<N>(V))
     return;
   StringRef S = getELFRelocationTypeName(Config->EMachine, Type);
-  fatal("Relocation " + S + " out of range");
+  error("Relocation " + S + " out of range");
 }
 
 template <unsigned N> static void checkAlignment(uint64_t V, uint32_t Type) {
   if ((V & (N - 1)) == 0)
     return;
   StringRef S = getELFRelocationTypeName(Config->EMachine, Type);
-  fatal("Improper alignment for relocation " + S);
+  error("Improper alignment for relocation " + S);
 }
 
 template <class ELFT> bool isGnuIFunc(const SymbolBody &S) {
@@ -1156,8 +1156,10 @@ unsigned AArch64TargetInfo::getDynRel(un
   if (Type == R_AARCH64_ABS32 || Type == R_AARCH64_ABS64)
     return Type;
   StringRef S = getELFRelocationTypeName(EM_AARCH64, Type);
-  fatal("Relocation " + S + " cannot be used when making a shared object; "
+  error("Relocation " + S + " cannot be used when making a shared object; "
                             "recompile with -fPIC.");
+  // Keep it going with a dummy value so that we can find more reloc errors.
+  return R_AARCH64_ABS32;
 }
 
 void AArch64TargetInfo::writeGotPlt(uint8_t *Buf, uint64_t Plt) const {
@@ -1397,8 +1399,10 @@ unsigned MipsTargetInfo<ELFT>::getDynRel
   if (Type == R_MIPS_32 || Type == R_MIPS_64)
     return R_MIPS_REL32;
   StringRef S = getELFRelocationTypeName(EM_MIPS, Type);
-  fatal("Relocation " + S + " cannot be used when making a shared object; "
+  error("Relocation " + S + " cannot be used when making a shared object; "
                             "recompile with -fPIC.");
+  // Keep it going with a dummy value so that we can find more reloc errors.
+  return R_MIPS_32;
 }
 
 template <class ELFT>

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=259435&r1=259434&r2=259435&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Mon Feb  1 17:28:21 2016
@@ -163,6 +163,8 @@ template <class ELFT> void Writer<ELFT>:
   openFile(Config->OutputFile);
   writeHeader();
   writeSections();
+  if (HasError)
+    return;
   fatal(Buffer->commit());
 }
 

Removed: lld/trunk/test/ELF/x86-64-reloc-32-error.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/x86-64-reloc-32-error.s?rev=259434&view=auto
==============================================================================
--- lld/trunk/test/ELF/x86-64-reloc-32-error.s (original)
+++ lld/trunk/test/ELF/x86-64-reloc-32-error.s (removed)
@@ -1,8 +0,0 @@
-// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/abs.s -o %tabs
-// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
-// RUN: not ld.lld -shared %tabs %t -o %t2 2>&1 | FileCheck %s
-// REQUIRES: x86
-
-  movl $big, %edx
-
-#CHECK: R_X86_64_32 out of range

Removed: lld/trunk/test/ELF/x86-64-reloc-32S-error.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/x86-64-reloc-32S-error.s?rev=259434&view=auto
==============================================================================
--- lld/trunk/test/ELF/x86-64-reloc-32S-error.s (original)
+++ lld/trunk/test/ELF/x86-64-reloc-32S-error.s (removed)
@@ -1,7 +0,0 @@
-// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
-// RUN: not ld.lld -shared %t -o %t2 2>&1 | FileCheck %s
-// REQUIRES: x86
-
-  movq _start - 0x1000000000000, %rdx
-
-#CHECK: R_X86_64_32S out of range

Copied: lld/trunk/test/ELF/x86-64-reloc-error.s (from r259431, lld/trunk/test/ELF/x86-64-reloc-32-error.s)
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/x86-64-reloc-error.s?p2=lld/trunk/test/ELF/x86-64-reloc-error.s&p1=lld/trunk/test/ELF/x86-64-reloc-32-error.s&r1=259431&r2=259435&rev=259435&view=diff
==============================================================================
--- lld/trunk/test/ELF/x86-64-reloc-32-error.s (original)
+++ lld/trunk/test/ELF/x86-64-reloc-error.s Mon Feb  1 17:28:21 2016
@@ -4,5 +4,7 @@
 // REQUIRES: x86
 
   movl $big, %edx
+  movq _start - 0x1000000000000, %rdx
 
-#CHECK: R_X86_64_32 out of range
+# CHECK: R_X86_64_32 out of range
+# CHECK: R_X86_64_32S out of range




More information about the llvm-commits mailing list