This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Dedupliсate FDEs when sections are ICFed.
ClosedPublic

Authored by grimar on Oct 17 2017, 5:10 AM.

Details

Summary

When LLD do ICF for 2 identical sections it leaves 2 duplicate entries in .eh_frame
pointing to the same address. After that it fixes .eh_frame_header's header,
so that it says it contains single FDE, though section itself contains 2
(it contains garbage data at tail).

As a result excessive entries in .eh_frame and excessive dummy data in .eh_frame_header
emited to output. Patch fixes that. This is PR34518.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.Oct 17 2017, 5:10 AM
ruiu added inline comments.Oct 24 2017, 8:41 PM
ELF/SyntheticSections.cpp
453–455 ↗(On Diff #119296)

// FDEs for garbage-collected or merged-by-ICF sections are dead.

457–459 ↗(On Diff #119296)

This code looks odd. The following code is more natural.

if (auto *D = dyn_cast<DefinedRegular>(&B))
  if (auto *Sec = cast_or_null<InputSectionBase>(D->Section))
    return Sec &&  ...;
return false;
grimar updated this revision to Diff 120228.Oct 25 2017, 3:49 AM
  • Addressed review comments.
ruiu accepted this revision.Oct 25 2017, 8:30 AM

LGTM

ELF/SyntheticSections.cpp
456 ↗(On Diff #120228)

You can remove Sec &&.

This revision is now accepted and ready to land.Oct 25 2017, 8:30 AM
This revision was automatically updated to reflect the committed changes.