This is an archive of the discontinued LLVM Phabricator instance.

ELF: Emit .eh_frame_hdr entries for FDEs with duplicate PCs.
ClosedPublic

Authored by pcc on Apr 8 2016, 3:03 PM.

Details

Summary

It is possible to have FDEs with duplicate PCs if ICF was able to merge
functions with FDEs, or if the input files for some reason contained duplicate
FDEs. We previously weren't handling this correctly when producing the
contents of the .eh_frame_hdr section; we were dropping entries and leaving
null entries at the end of the section, which confused consumers of unwind
data, such as the backtrace() function.

Fix the bug by collecting the FDEs into a std::multimap rather than a std::map.

Diff Detail

Repository
rL LLVM

Event Timeline

pcc updated this revision to Diff 53096.Apr 8 2016, 3:03 PM
pcc retitled this revision from to ELF: Emit .eh_frame_hdr entries for FDEs with duplicate PCs..
pcc updated this object.
pcc added reviewers: ruiu, rafael.
pcc added a subscriber: llvm-commits.
rafael edited edge metadata.Apr 8 2016, 6:23 PM
rafael added a subscriber: rafael.

How hard would it be to discard that part of the .eh_frame? Or at least not
include it in the index (reduce fde_count).

If I understand it correctly with this patch we create an empty range in
the binary search table, which is a bit odd.

pcc added a comment.Apr 8 2016, 7:43 PM

It seems feasible, I'll see if I can do it. In the meantime, this fixes the issue with backtrace(), and also matches gold's behavior, so maybe we can land this as a first step with a FIXME.

I was also thinking about cases where the unwind info for functions with identical bodies was semantically different. For example, I suppose you might be able to have functions with identical bodies but different personality functions. If that's possible, I suppose we may need to inhibit ICF in such cases and do something completely different here.

pcc updated this revision to Diff 53146.Apr 9 2016, 12:24 PM
pcc edited edge metadata.

Set FDE count in .eh_frame_hdr correctly instead

This revision was automatically updated to reflect the committed changes.