This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - ICF: handle SHF_LINK_ORDER sections properly.
AbandonedPublic

Authored by grimar on Sep 12 2017, 6:07 AM.

Details

Reviewers
ruiu
rafael
Summary

ICF code currently handles SHF_LINK_ORDER section only for ARM.
Though it is possible (and testcase shows that) to use them in
other targets.

Testcase provided would crash before such change. Patch
adds verbose reporting when removing of SHF_LINK_ORDER sections
and also makes logic to work for all targets instead of only ARM.

Diff Detail

Event Timeline

grimar created this revision.Sep 12 2017, 6:07 AM
ruiu edited edge metadata.Sep 12 2017, 5:42 PM

Why do you want to do this? Why don't you just remove EM_ARM?

In D37739#868992, @ruiu wrote:

Why do you want to do this? Why don't you just remove EM_ARM?

Reporting sections removed by ICF is consistent, I supposed we want it.
I also using --verbose reporting in my testcase (most of ICF tests use --verbose messages for checking,
so it is also a consistent way, though I sure can write regular testcase).
Do you think we should not do that, but why not ?

ruiu added a comment.Sep 15 2017, 4:24 PM

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?

In 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).

grimar abandoned this revision.Sep 22 2017, 9:11 AM

Abandoned in favor of D38180.