[PATCH] D43284: [ELF] Simplify handling of AT section attribute.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 14 07:19:24 PST 2018


Igor Kudrin via Phabricator <reviews at reviews.llvm.org> writes:

What was broken by the current behavior? Should this change be
backported to 6.0?

> Index: ELF/Writer.cpp
> ===================================================================
> --- ELF/Writer.cpp
> +++ ELF/Writer.cpp
> @@ -821,8 +821,6 @@
>    p_align = std::max(p_align, Sec->Alignment);
>    if (p_type == PT_LOAD)
>      Sec->PtLoad = this;
> -  if (Sec->LMAExpr)
> -    ASectionHasLMA = true;
>  }
>  
>  // The beginning and the ending of .rel[a].plt section are marked
> @@ -1654,6 +1652,7 @@
>    Load->add(Out::ElfHeader);
>    Load->add(Out::ProgramHeaders);
>  
> +  bool FirstLoadSection = true;
>    for (OutputSection *Sec : OutputSections) {
>      if (!(Sec->Flags & SHF_ALLOC))
>        break;
> @@ -1666,14 +1665,15 @@
>      // different flags or is loaded at a discontiguous address using AT linker
>      // script command.
>      uint64_t NewFlags = computeFlags(Sec->getPhdrFlags());
> -    if ((Sec->LMAExpr && Load->ASectionHasLMA) ||
> +    if ((Sec->LMAExpr && !FirstLoadSection) ||

Instead of adding FirstLoadSection, you can use:

Load->LastSec != Out::ProgramHeaders.

Please also add a comment saying what we are doing: including the
headers in the first PT_LOAD even if it has an AT.

Cheers,
Rafael


More information about the llvm-commits mailing list