This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Support renaming of LSDA section
ClosedPublic

Authored by int3 on Nov 10 2021, 10:07 AM.

Details

Reviewers
gkm
oontvoo
Group Reviewers
Restricted Project
Commits
rGa2404f11c77e: [lld-macho] Support renaming of LSDA section
Summary

Previously, our unwind info finalization logic assumed that the LSDA
section referenced by __compact_unwind was already finalized before
__TEXT,__unwind_info itself. However, that assumption could be broken
by the use of -rename_section -- it could be (and is) used to move
__gcc_except_tab it into a different segment later in the file.
(__TEXT is always the first non-zerofill segment, so any rename
basically guarantees that the section will be ordered after
__unwind_info.)

To handle this case, we compare LSDA relocations instead of their final
values in UnwindInfoSection::finalize(), and we actually relocate
those LSDAs in UnwindInfoSection::writeTo(). In order to do this, we
need an easy way to track which Symbol a given CUE corresponds to. My
solution was to change our cuPtrVector into a vector of indices, with
each index used for both the symbols vector (symbolsVec) as well as
the CUE vector (cuVector).

This change seems perf neutral. Numbers for linking chromium_framework
on my 16 core Mac Pro:

           base           diff           difference (95% CI)
sys_time   1.248 ± 0.025  1.245 ± 0.026  [  -1.3% ..   +0.8%]
user_time  3.588 ± 0.045  3.587 ± 0.037  [  -0.6% ..   +0.5%]
wall_time  4.605 ± 0.069  4.595 ± 0.069  [  -1.0% ..   +0.5%]
samples    42             26

Diff Detail

Event Timeline

int3 created this revision.Nov 10 2021, 10:07 AM
Herald added a project: Restricted Project. · View Herald Transcript
int3 requested review of this revision.Nov 10 2021, 10:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 10 2021, 10:07 AM
oontvoo added inline comments.
lld/MachO/UnwindInfoSection.cpp
132

for consistency, can we stick to one naming convention? :) (hungarian notation or not?)
does cuEntrieswork?

134

comment on what the significance of the entries pointed to by these indices is?

P.S: from reading further, it's an indirection from the page's index -> the cuVector's index .... would be good to have clarification

553

shouldn't this be "size_t"? (because entriesWithLsda is storing the indices not the entries themselves?)

int3 added inline comments.Nov 10 2021, 10:48 AM
lld/MachO/UnwindInfoSection.cpp
132

this is an existing name, but yes, happy to change it. cuEntries sounds good.

134

there's a further comment on line 406. (It's not just an indirection from the page's index... it's an indirection used for pretty much all accesses into the cuVector.)

405–410

this is the comment I was referring to

553

level2PagesOffset is the offset of the encoded values, not the intermediate structures :) so we're calculating the offsets after encoding here

int3 updated this revision to Diff 386251.Nov 10 2021, 10:54 AM
int3 marked an inline comment as done.

rename

oontvoo accepted this revision.Nov 10 2021, 4:17 PM

LG

lld/MachO/UnwindInfoSection.cpp
132

Thanks!

This revision is now accepted and ready to land.Nov 10 2021, 4:17 PM
This revision was automatically updated to reflect the committed changes.