[PATCH] D44376: [ELF] - Drop special flags for empty output sections.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 14 13:30:40 PDT 2018


Rui Ueyama via Phabricator <reviews at reviews.llvm.org> writes:

> ruiu added inline comments.
>
>
> ================
> Comment at: lld/trunk/ELF/LinkerScript.cpp:859-862
> +    if (IsEmpty && isDiscardable(*Sec)) {
>        Sec->Live = false;
>        Cmd = nullptr;
>      }
> ----------------
> I believe this patch is correct, but this logic seems a bit weird to me. If an section is empty, we reset the section flag, but we also discard the section. If the section is discarded, why does its flag matter? Why do you have to reset it just before discarding it?

To handle the !isDiscardable case. The new code is:

    if (IsEmpty)
      Sec->Flags = Flags & (SHF_ALLOC | SHF_WRITE | SHF_EXECINSTR);

    if (IsEmpty && isDiscardable(*Sec)) {

So if the section is empty but must be kept for some other reason we
update the flags.

Cheers,
Rafael


More information about the llvm-commits mailing list