[PATCH] D28626: RFC: Generalize inverted gc dependencies

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 13 07:21:51 PST 2017


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

> ruiu added inline comments.
>
>
> ================
> Comment at: lld/ELF/InputFiles.cpp:325
>                Twine(Sec.sh_link));
> -      auto *IS = cast<InputSection<ELFT>>(Sections[Sec.sh_link]);
> -      IS->DependentSection = Sections[I];
> +      if (uint32_t Link = Sec.sh_link) {
> +        auto *IS = cast<InputSection<ELFT>>(Sections[Link]);
> ----------------
> Does this mean that there is a section with SHF_LINK_ORDER bit but with a null sh_link? It  seems like a broken object file to me.

Not sure it is broken with the current spec:

SHF_LINK_ORDER
    This flag adds special ordering requirements for link editors. The
    requirements apply if the sh_link field of this section's header
    references another section (the linked-to section).

In any case, the idea of the patch is precisely to use SHF_LINK_ORDER
to invert the relocation dependencies, so sh_link doesn't have to be set
in that case.

> ================
> Comment at: lld/ELF/MarkLive.cpp:238-244
> +    if (Sec->Flags & SHF_LINK_ORDER) {
> +      forEachSuccessor<ELFT>(
> +          cast<InputSection<ELFT>>(*Sec), [=](ResolvedReloc<ELFT> R) {
> +            cast<InputSection<ELFT>>(R.Sec)->DependentSections.push_back(Sec);
> +          });
> +      continue;
> +    }
> ----------------
> Why do you need this code? It seems you initializes DependentSections in InputFiles.

Just the sh_link dependencies, no the relocation ones.

Cheers,
Rafael


More information about the llvm-commits mailing list