Skip to content

Commit

Permalink
Add Microsoft.NET.HostModel.TestData (#505)
Browse files Browse the repository at this point in the history
Adds a project with binary Mach-O files to test the ad-hoc signing in Microsoft.NET.HostModel.
  • Loading branch information
jtschuster authored Oct 23, 2024
1 parent a301793 commit 24f902e
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
12 changes: 12 additions & 0 deletions src/Microsoft.NET.HostModel.TestData/MachO/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

int add(int a, int b)
{
return a + b;
}

int main()
{
return add(2, 3) - add(1, 4);
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<Project Sdk="Microsoft.Build.NoTargets">
<ItemGroup>
<None Remove="MachO\src\*" />
</ItemGroup>

<ItemGroup>
<MachOArch Include="arm64" />
<MachOArch Include="x86_64" />
<MachOCodesignOption Include="signed" />
<MachOCodesignOption Include="unsigned" />
<MachOCodesignOption Include="buildonly" />
</ItemGroup>

<Target Name="GenerateMachOBinaries">
<ItemGroup>
<_MachObjectFile Include="@(MachOArch)">
<Codesign>%(MachOCodesignOption.Identity)</Codesign>
</_MachObjectFile>
<MachObjectFile Include="@(_MachObjectFile->'$(MSBuildThisFileDirectory)MachO/%(Identity)/a.%(Codesign).out')" >
<Arch>%(_MachObjectFile.Identity)</Arch>
</MachObjectFile>
</ItemGroup>

<MakeDir Directories="%(MachObjectFile.RelativeDir)" />
<Exec Command="clang $(MSBuildThisFileDirectory)MachO/src/main.c -o %(MachObjectFile.Identity) -arch %(Arch)" />
<Exec Command="codesign --sign - %(MachObjectFile.Identity)"
Condition="'%(Codesign)' == 'signed'" />
<Exec Command="codesign --remove-signature %(MachObjectFile.Identity)"
Condition="'%(Codesign)' == 'unsigned'" />
</Target>

</Project>
5 changes: 5 additions & 0 deletions src/Microsoft.NET.HostModel.TestData/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Microsoft.NET.HostModel.TestData

This project contains binary Mach-O files that are used to test the `Microsoft.NET.HostModel` implementation of ad-hoc signing.

To produce the binary files, run `dotnet build -t:GenerateMachOBinaries` on a macOS machine with `clang` installed. The version of `clang` used for the files in the current commit is `Apple clang version 16.0.0 (clang-1600.0.26.3)`.

0 comments on commit 24f902e

Please sign in to comment.