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

Rafael Ávila de Espíndola via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 14 13:30:46 PDT 2018


rafael added a comment.

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


Repository:
  rL LLVM

https://reviews.llvm.org/D44376





More information about the llvm-commits mailing list