This is an archive of the discontinued LLVM Phabricator instance.

Add MachO signature verification test
ClosedPublic

Authored by nuriamari on Sep 15 2021, 11:06 AM.

Details

Reviewers
gkm
int3
drodriguez
thakis
Group Reviewers
Restricted Project
Commits
rGaaf00f3f19c1: Add MachO signature verification test
Summary

Add a test to ensure that MachO files including
a LC_CODE_SIGNATURE load command produced by lld
are signed correctly.

Diff Detail

Event Timeline

nuriamari created this revision.Sep 15 2021, 11:06 AM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a reviewer: Restricted Project. · View Herald Transcript
nuriamari published this revision for review.Sep 15 2021, 11:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 15 2021, 11:14 AM
int3 added inline comments.Sep 15 2021, 11:43 AM
lld/test/MachO/Inputs/code-signature-check.py
11

can we have a docstring describing what this script does?

thevinster added inline comments.
lld/test/MachO/Inputs/code-signature-check.py
11

+1 - Usage of the script would also be nice for future reader.

int3 added inline comments.Sep 15 2021, 12:08 PM
lld/test/MachO/adhoc-codesign-hash.s
17

nit: try to vertically align where possible (same for lines below)

oontvoo added inline comments.
lld/test/MachO/Inputs/code-signature-check.py
2

Any chance this could be omitted for portability? (since you've already invoked the script with %python below)?
(also is python3 a must?)

lld/test/MachO/adhoc-codesign-hash.s
17–34

Perhaps consider using variables here to avoid duplication? (also easier for future updates?)

(suggested diff is in-complete -- only included one eg)

nuriamari updated this revision to Diff 372804.Sep 15 2021, 2:15 PM
nuriamari marked 4 inline comments as done.

Address shebang, comment and spacing related feeback

nuriamari added inline comments.Sep 15 2021, 2:17 PM
lld/test/MachO/Inputs/code-signature-check.py
2

I'll remove the shebang, but the script does require at least python3.5 for the typing module.

lld/test/MachO/adhoc-codesign-hash.s
17–34

I haven't been able to get what you are suggesting working. Are FileCheck capture variables usable within a run command?

int3 accepted this revision.Sep 15 2021, 3:34 PM

lgtm

lld/test/MachO/adhoc-codesign-hash.s
17–34

What @oontvoo left out was how to define variables for FileCheck :) you'll want something like -D#DATAOFF=16400 here for the substitution to work. Then you can reference it via [[#DATAOFF]]. (The # indicates that the value is an integer. It only matters if you want to do arithmetic on the values, which doesn't apply in this case, but it's nice to use # anyway for clarity.)

This revision is now accepted and ready to land.Sep 15 2021, 3:34 PM
nuriamari updated this revision to Diff 372826.Sep 15 2021, 4:02 PM

Correct docstring argument description

What @oontvoo left out was how to define variables for FileCheck :) you'll want something like -D#DATAOFF=16400 here for the substitution to work. Then you can reference it via #DATAOFF. (The # indicates that the value is an integer. It only matters if you want to do arithmetic on the values, which doesn't apply in this case, but it's nice to use # anyway for clarity.)

Ah, yes - I'd forgot that part. Thanks for clarifying it!

not sure why this comment is not in-lined anymore. 🤔 @nuriamari : Do you use arc to update this patch?

What @oontvoo left out was how to define variables for FileCheck :) you'll want something like -D#DATAOFF=16400 here for the substitution to work. Then you can reference it via #DATAOFF. (The # indicates that the value is an integer. It only matters if you want to do arithmetic on the values, which doesn't apply in this case, but it's nice to use # anyway for clarity.)

Ah, yes - I'd forgot that part. Thanks for clarifying it!

not sure why this comment is not in-lined anymore. 🤔 @nuriamari : Do you use arc to update this patch?

Yes, I am using arc to update the patch, I did notice inline comments from previous revisions disappear, but if you change the diff viewer to show the first revision, the inline comments remain. In any case, I will add the variables to the FileCheck lines. Thanks!

nuriamari updated this revision to Diff 372923.Sep 16 2021, 6:53 AM

Use FileCheck variables in test

This revision was automatically updated to reflect the committed changes.