[PATCH] D81988: [ELF] Fix a dyn_cast<Defined>(nullptr) crash if a local symbol appears in InputFile::symbols

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 17 00:30:18 PDT 2020


jhenderson added a comment.

Thanks for the fix! It looks reasonable to me, but before approving, I wanted to ask would we be better off emitting some kind of warning or error about the out-of-order list earlier on?



================
Comment at: lld/ELF/InputSection.cpp:350
   for (Symbol *b : file->getSymbols())
-    if (auto *d = dyn_cast<Defined>(b))
+    if (auto *d = dyn_cast_or_null<Defined>(b))
       if (d->section == this && d->value <= off && off < d->value + d->size)
----------------
It might be worth a comment saying under what conditions `b` can be nullptr.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81988/new/

https://reviews.llvm.org/D81988





More information about the llvm-commits mailing list