[PATCH] D49814: When getting an error location, don't assume that all sections prior to a given offset can be cast to an InputSection

Sterling Augustine via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 25 11:46:19 PDT 2018


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

Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D49814

Files:
  ELF/Target.cpp


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49814.157329.patch
Type: text/x-patch
Size: 851 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180725/12bde2d8/attachment.bin>


More information about the llvm-commits mailing list