This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho][NFC] Handle GOT bindings and regular bindings more uniformly
ClosedPublic

Authored by int3 on Aug 25 2020, 1:20 PM.

Details

Summary

Previously, the BindingEntry struct could only store bindings to offsets
within InputSections. Since the GOTSection and TLVPointerSections are
OutputSections, I handled those in a separate code path. However, this
makes it awkward to support weak bindings properly without code
duplication. This diff allows BindingEntries to point directly to
OutputSections, simplifying the upcoming weak binding implementation.

Along the way, I also converted a bunch of functions taking references
to symbols to take pointers instead. Given how much casting we do for
Symbol (especially in the upcoming weak binding diffs), it's cleaner
this way.

Diff Detail

Event Timeline

int3 created this revision.Aug 25 2020, 1:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2020, 1:20 PM
int3 requested review of this revision.Aug 25 2020, 1:20 PM
smeenai accepted this revision.Aug 26 2020, 4:02 PM
smeenai added a subscriber: smeenai.

LGTM; this is a nice cleanup.

lld/MachO/SyntheticSections.cpp
109

I get that we're accounting for the got and tlvPointers the same as all other bindings now, but how come we don't need the bindings.size() != 0 check at all anymore?

This revision is now accepted and ready to land.Aug 26 2020, 4:02 PM
int3 added inline comments.Aug 26 2020, 4:10 PM
lld/MachO/SyntheticSections.cpp
109

oops -- I'd meant to move this method to the header, not delete it

(we don't have a test that checks to make sure we don't emit a BindingSection when we don't need one... not super important since it doesn't affect correctness, but I'll see if it's easy to add)

int3 updated this revision to Diff 288150.Aug 26 2020, 6:33 PM

fix, add test

This revision was landed with ongoing or failed builds.Aug 26 2020, 7:27 PM
This revision was automatically updated to reflect the committed changes.