Page MenuHomePhabricator

[lld-macho] Add support for -add_empty_section
ClosedPublic

Authored by keith on Jan 19 2022, 10:32 PM.

Details

Reviewers
int3
Group Reviewers
Restricted Project
Commits
rGa6298fb16063: [lld-macho] Add support for -add_empty_section
Summary

This is a ld64 option equivalent to -sectcreate seg sect /dev/null
that's useful for creating sections like the RESTRICT section.

Diff Detail

Event Timeline

keith created this revision.Jan 19 2022, 10:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 19 2022, 10:32 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Herald added a subscriber: dang. · View Herald Transcript
keith requested review of this revision.Jan 19 2022, 10:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 19 2022, 10:32 PM
int3 added a subscriber: int3.Jan 19 2022, 11:55 PM

From the ld64 manpage:

-add_empty_section segname sectname
           An empty section named sectname in the segment segname. If any of the inputs contains a section (segname,sectname), that section will be included in the output, and this option will be ignored.

Can we add a test for the case where the inputs also contain a section of the same name?

lld/test/MachO/sectcreate.s
25

nit: I believe the double-underscore prefix is intended to be reserved for "special" section names, and user-created sections should just have regular un-prefixed names

keith updated this revision to Diff 404211.Jan 28 2022, 6:52 PM

Improve test

keith updated this revision to Diff 404212.Jan 28 2022, 6:53 PM
keith marked an inline comment as done.

Add overlapping section

keith added a comment.Jan 28 2022, 6:53 PM

Ah nice call, I added another case where it overlaps with sectcreate, and added one where it overlaps with DATA,data

int3 accepted this revision.Jan 29 2022, 9:09 PM

Thanks!

This revision is now accepted and ready to land.Jan 29 2022, 9:09 PM
This revision was automatically updated to reflect the committed changes.