[PATCH] D37520: [ELF] - Fix removing of unused synthetic sections.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 25 10:12:10 PDT 2017
ruiu 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)
----------------
grimar wrote:
> 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.
So you are saying that .got output section is not created for `.got : { *(.got) }` if .got synthetic input section is empty, that is what I expected.
But what about some output section .foo where it is created as `.foo : { *(.bar) }`, if no input file have .bar section? Do we still create .foo?
If yes, that behavior is inconsistent.
If no, there must be a place we remove empty output sections. Doing the same thing here doesn't make sense.
https://reviews.llvm.org/D37520
More information about the llvm-commits
mailing list