[PATCH] D37520: [ELF] - Fix removing of unused synthetic sections.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 25 05:05:15 PDT 2017


grimar added inline comments.


================
Comment at: ELF/Writer.cpp:1205-1209
+    bool IsEmpty = llvm::all_of(OS->Commands, [](BaseCommand *B) {
+      auto *ISD = dyn_cast<InputSectionDescription>(B);
+      return ISD && ISD->Sections.empty();
+    });
+    if (IsEmpty)
----------------
ruiu wrote:
> I think I do not understand this code. You don't need to use all_of, right? The only way in which OS becomes empty is (1) it contains only one InputSectionDescription and (2) that InputSectionDescription is empty, no?
No. If OS has 2 or more ISDs which are empty, it is also empty.
For example in script from testcase we have ".got  : { *(.got) *(.got) }",
which means we have OS `.got` and 2 ISDs, one has input section and one is empty from start.
When we remove unused input section from first ISD it becomes empty, and we want to remove whole OS.
For that we have to check if all ISDs are empty.


https://reviews.llvm.org/D37520





More information about the llvm-commits mailing list