This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Make __LINKEDIT sections contiguous
ClosedPublic

Authored by int3 on Jul 27 2020, 6:11 PM.

Details

Reviewers
compnerd
Group Reviewers
Restricted Project
Commits
rG98210796e108: [lld-macho] Make __LINKEDIT sections contiguous
Summary

codesign (or more specifically libstuff) checks that each section in
__LINKEDIT ends where the next one starts -- no gaps are permitted. This
diff achieves it by aligning every section's start and end points to
WordSize.

Remarks: ld64 appears to satisfy the constraint by adding padding bytes
when generating the __LINKEDIT data, e.g. by emitting BIND_OPCODE_DONE
(which is a 0x0 byte) repeatedly. I think the approach this diff takes
is a bit more elegant, but I'm not sure if it's too restrictive. In
particular, it assumes padding always uses the zero byte. But we can
revisit this later.

Diff Detail

Event Timeline

int3 created this revision.Jul 27 2020, 6:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 27 2020, 6:11 PM
compnerd accepted this revision.Jul 28 2020, 9:10 AM
compnerd added a subscriber: compnerd.

I think that the assumption that you can use a 0 byte is dangerous (in theory, probably not practice). Please add a large comment explaining the reasoning and divergence into the code.

This revision is now accepted and ready to land.Jul 28 2020, 9:10 AM
This revision was automatically updated to reflect the committed changes.