[PATCH] D51743: [ELF] Check if LinkSec is nullptr when initializing SHF_LINK_ORDER sections

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 6 15:59:40 PDT 2018


ruiu added inline comments.


================
Comment at: ELF/InputFiles.cpp:481
     if (Sec.sh_flags & SHF_LINK_ORDER) {
-      if (Sec.sh_link >= this->Sections.size())
+      InputSectionBase *LinkSec = Sec.sh_link < this->Sections.size()
+                                      ? this->Sections[Sec.sh_link]
----------------
It feels like setting to a nullptr is a little bit tricky. I'd probably keep the original code for this line, and add another null check after `InputSectionBase *LinkSec = this->Sections[Sec.sh_link];`


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D51743





More information about the llvm-commits mailing list