[PATCH] D50419: [ELF] Skip non-InputSection's in getErrPlace

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 7 16:39:32 PDT 2018


MaskRay created this revision.
MaskRay added a reviewer: ruiu.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.

Otherwise MergeInputSection's can also be iterated and will cause cast error.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D50419

Files:
  ELF/Target.cpp


Index: ELF/Target.cpp
===================================================================
--- ELF/Target.cpp
+++ ELF/Target.cpp
@@ -91,8 +91,8 @@
 
 template <class ELFT> static ErrorPlace getErrPlace(const uint8_t *Loc) {
   for (InputSectionBase *D : InputSections) {
-    auto *IS = cast<InputSection>(D);
-    if (!IS->getParent())
+    auto *IS = dyn_cast<InputSection>(D);
+    if (!IS || !IS->getParent())
       continue;
 
     uint8_t *ISLoc = IS->getParent()->Loc + IS->OutSecOff;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50419.159623.patch
Type: text/x-patch
Size: 492 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180807/e77bcf95/attachment.bin>


More information about the llvm-commits mailing list