[PATCH] D43574: [ELF] - Introduce getInputSections() helper.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 22 09:03:04 PST 2018


George Rimar via Phabricator <reviews at reviews.llvm.org> writes:

> grimar added inline comments.
>
>
> ================
> Comment at: lld/trunk/ELF/Writer.cpp:1395
>      // section description, we remove it from the output.
> -    bool IsEmpty = llvm::all_of(OS->SectionCommands, [](BaseCommand *B) {
> -      if (auto *ISD = dyn_cast<InputSectionDescription>(B))
> -        return ISD->Sections.empty();
> -      return false;
> -    });
> -    if (IsEmpty)
> +    if (getInputSections(OS).empty())
>        OS->Live = false;
> ----------------
> jhenderson wrote:
>> This isn't a direct equivalent of what was there before, as it only takes account of InputSectionDescription commands, and not other commands, such as BYTE() or symbol assignments. This has an effect on the layout, though I haven't conclusively determined what (it affects the "Rank" somehow). See PR36475.
> You right. 
> What we do is set output section flags to flags of synthetic input section. Then we remove this empty section here and mark output
> section as dead.
> `adjustSectionsBeforeSorting` might resurrect it and reassign flags to different ones. 
> If script would not contain empty synthetic section in output section description, I think flags would be the same as now.
> So, this is definitely not a direct equivalent, but I am not sure if it is an issue ?

We should at least have a test showing the difference.

Cheers,
Rafael


More information about the llvm-commits mailing list