[PATCH] D27973: [ELF] - Do not call fatal() in Target.cpp, call error() instead.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 20 01:51:25 PST 2016


grimar created this revision.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar, evgeny777.

That is useful from many sides I think.
We probably would want to avoid fatal() if we can in context of librarification,
but for me reason of that patch is to help https://reviews.llvm.org/D27900 go.

https://reviews.llvm.org/D27900 changes errors reporting to something like
error: text1
note: text2
note: text3

where hint used to provide additional information about location. In that case
I can't just call fatal() because user will not see notes after that what adds additional complication to handle.
What is good that Target.cpp looks the only such place and this patch changes it.

Also it adds testcase with broken relocation. Previously we did not have any,
It checks that error() instead of fatal() works fine.


https://reviews.llvm.org/D27973

Files:
  ELF/Target.cpp
  test/ELF/invalid/Inputs/invalid-relocation-x64.elf
  test/ELF/invalid/invalid-relocation-x64.s


Index: test/ELF/invalid/invalid-relocation-x64.s
===================================================================
--- test/ELF/invalid/invalid-relocation-x64.s
+++ test/ELF/invalid/invalid-relocation-x64.s
@@ -0,0 +1,3 @@
+## invalid-relocation-x64.elf contains relocation with invalid index
+# RUN: not ld.lld %p/Inputs/invalid-relocation-x64.elf -o %t2 2>&1 | FileCheck %s
+# CHECK: unrecognized reloc 153
Index: ELF/Target.cpp
===================================================================
--- ELF/Target.cpp
+++ ELF/Target.cpp
@@ -841,7 +841,7 @@
     write64le(Loc, Val);
     break;
   default:
-    fatal(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
+    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
   }
 }
 
@@ -1010,7 +1010,7 @@
     or32be(Loc, Val & 0x3FFFFFC);
     break;
   default:
-    fatal(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
+    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
   }
 }
 
@@ -1188,7 +1188,7 @@
     break;
   }
   default:
-    fatal(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
+    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
   }
 }
 
@@ -1439,7 +1439,7 @@
     or32AArch64Imm(Loc, Val);
     break;
   default:
-    fatal(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
+    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
   }
 }
 
@@ -1549,7 +1549,7 @@
     write32le(Loc, Val >> 32);
     break;
   default:
-    fatal(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
+    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
   }
 }
 
@@ -1859,7 +1859,7 @@
                   (Val & 0x00ff));           // imm8
     break;
   default:
-    fatal(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
+    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
   }
 }
 
@@ -2307,7 +2307,7 @@
     applyMipsPcReloc<E, 32, 0>(Loc, Type, Val);
     break;
   default:
-    fatal(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
+    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27973.82069.patch
Type: text/x-patch
Size: 2183 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161220/195df9de/attachment.bin>


More information about the llvm-commits mailing list