This is an archive of the discontinued LLVM Phabricator instance.

[MachOYAML] Simplify the section data emitting function. NFC.
ClosedPublic

Authored by Higuoxing on Aug 12 2020, 2:15 AM.

Details

Summary

This patch helps simplify some codes in writeSectionData() function.

Diff Detail

Event Timeline

Higuoxing created this revision.Aug 12 2020, 2:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 12 2020, 2:15 AM
Higuoxing requested review of this revision.Aug 12 2020, 2:15 AM
jhenderson accepted this revision.Aug 12 2020, 2:20 AM

Looks fine. I'm slightly nervous by the hard-coded 16 for the section name max length, but it's probably okay for now, and is no worse than what was there before.

This revision is now accepted and ready to land.Aug 12 2020, 2:20 AM
grimar added a comment.EditedAug 12 2020, 2:39 AM

Looks fine. I'm slightly nervous by the hard-coded 16 for the section name max length, but it's probably okay for now, and is no worse than what was there before.

Why don't we use something like
assert(sizeof(segname) == 16), or a static assert for segname, or strncmp(&Sec.segname[0], "__DWARF", sizeof(segname)))?

Higuoxing updated this revision to Diff 285059.Aug 12 2020, 6:09 AM

Use sizeof() operator to get rid of hardcoded length.

grimar accepted this revision.Aug 12 2020, 6:10 AM

LGTM