This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objcopy][MachO] Add support for LC_CODE_SIGNATURE
ClosedPublic

Authored by alexander-shaposhnikov on Jun 12 2020, 2:36 PM.

Details

Summary

This diff adds support for copying binaries containing a LC_CODE_SIGNATURE load command .

Test plan: make check-all

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: abrachet. · View Herald Transcript

Not sure if this will also fix: "llvm-objcopy: error: unsupported load command (cmd=0x1d)" error. https://bugs.llvm.org/show_bug.cgi?id=46306

hiraditya added a comment.EditedJun 13 2020, 7:00 AM

Thanks a lot for fixing this, this was blocking me earlier yesterday and @smeenai asked me to reach out to you.

MaskRay added inline comments.Jun 13 2020, 5:33 PM
llvm/test/tools/llvm-objcopy/MachO/code_signature_lc.test
4

Does this test need CHECK lines?

Looks reasonable on the surface, but I don't have the Mach-O knowledge to confirm it, so best get someone else to give the LGTM.

llvm/test/tools/llvm-objcopy/MachO/code_signature_lc.test
4

I don't think so, strictly? cmp does the job fine, since we know the load command is in the input (citation: presumably some yaml2obj test), and it does a binary diff.

That being said, a check line might be helpful to prevent user error in the input.

smeenai accepted this revision.Jun 15 2020, 5:27 PM

LGTM from the Mach-O side.

llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
222

Typo: covention -> convention

IIRC the reason for this convention is that dyld3 assumes the text segment starts at file offset 0, so the Mach-O header is counted as part of the text segment. See the comment about dyld3 in Writer.cpp in D75382.

234

Does this comment need updating? It appears the code signature is at the end.

llvm/tools/llvm-objcopy/MachO/Object.h
309

Typo: comamnd -> command

This revision is now accepted and ready to land.Jun 15 2020, 5:27 PM
alexander-shaposhnikov marked an inline comment as done.Jun 15 2020, 5:52 PM
alexander-shaposhnikov added inline comments.
llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
234

yeah, thanks, I'll update the comment

This revision was automatically updated to reflect the committed changes.