[PATCH] D38180: [ELF] - ICF: improve support of SHF_LINK_ORDER sections.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 27 20:52:40 PDT 2017


ruiu added inline comments.


================
Comment at: ELF/ICF.cpp:278
 bool ICF<ELFT>::equalsConstant(const InputSection *A, const InputSection *B) {
-  if (A->NumRelocations != B->NumRelocations || A->Flags != B->Flags ||
-      A->getSize() != B->getSize() || A->Data != B->Data)
+  if (!A || !B || A->NumRelocations != B->NumRelocations ||
+      A->Flags != B->Flags || A->getSize() != B->getSize() ||
----------------
You shouldn't make this change -- you can check it on the caller side.


================
Comment at: ELF/ICF.cpp:436-437
       Sections[Begin]->replace(Sections[I]);
+      if (InputSection *LinkOrder = Sections[I]->getLinkOrderSec())
+        log("  removed " + LinkOrder->Name);
     }
----------------
This is pretty odd piece of code. You do not call `replace` on LinkOrder section, but you are reporting that you have removed it. It looks buggy even if it is not buggy.


================
Comment at: ELF/InputSection.cpp:244
 
+InputSection *InputSectionBase::getLinkOrderSec() const {
+  InputSection *Ret = nullptr;
----------------
Why don't you just add a `LinkOrderSection *` member to InputSection?


https://reviews.llvm.org/D38180





More information about the llvm-commits mailing list