[PATCH] D43234: [ELF] - Fix case of using both --icf and --symbol-ordering-file together.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 15 10:23:13 PST 2018


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

> Index: ELF/Writer.cpp
> ===================================================================
> --- ELF/Writer.cpp
> +++ ELF/Writer.cpp
> @@ -1043,6 +1043,13 @@
>          continue;
>        int &Priority = SectionOrder[D->Section];
>        Priority = std::min(Priority, SymbolOrder.lookup(D->getName()));
> +
> +      // If ICF merged sections, we want to use the highest priority.
> +      if (D->Section != D->Section->Repl) {
> +        int &ReplPriority = SectionOrder[D->Section->Repl];
> +        Priority = std::min(Priority, ReplPriority);
> +        ReplPriority = Priority;
> +      }
>      }
>    }
>    return SectionOrder;
>

I think this is reasonable. The assumption is that satisfying a layout
that shows up early in the file is more important than one that shows up
late.

But do we even have to have replaced sections in the map? They will
never be layout.

That is, can't we just have

  int &Priority = SectionOrder[D->Section->Repl];
  Priority = std::min(Priority, SymbolOrder.lookup(D->getName()));

Cheers,
Rafael


More information about the llvm-commits mailing list