[PATCH] D37739: [ELF] - ICF: handle SHF_LINK_ORDER sections properly.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 18 05:25:26 PDT 2017


grimar added a comment.

In https://reviews.llvm.org/D37739#872899, @ruiu wrote:

> This seems to be another instance of attempting to "fix" an issue at surface-level where deeper planning is needed.
>
> Current ICF doesn't actually work for SHF_LINK_ORDER, no? Assume you have three sections A, B and C, where C depends on A but B doesn't have any dependent section. Do you think A and B can be merged? No, because A and B are not really identical. The problem is that ICF doesn't take section dependencies into account. I don't want you to update this patch immediately, but can you please think about that to come up with a plan how you would deal with it and explain it to me?


I think probably the most correct way to handle this is to merge A and B only if their dependent sections are equal.
So if we have equal sections A and B and SHF_LINK_ORDER sections C and D where C depends on A and D depends on B,
we can merge A and B and just drop C or D, so that one leaved alive will still depend on A/B.

We should be able to check if dependent sections are equal using existent infrastructure I think (that will require scanning
relocations for them and doing other things which ICF code already do).


https://reviews.llvm.org/D37739





More information about the llvm-commits mailing list