Add support for building ARM64 native only eBPF for Windows. (#3921)
* Add support for building ARM64 native only eBPF for Windows. Signed-off-by: Alan Jowett <alan.jowett@microsoft.com> * PR feedback Signed-off-by: Alan Jowett <alan.jowett@microsoft.com> --------- Signed-off-by: Alan Jowett <alan.jowett@microsoft.com> Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
This commit is contained in:
Родитель
b312e0725e
Коммит
811c060983
|
@ -59,19 +59,24 @@ jobs:
|
|||
|
||||
|
||||
onebranch:
|
||||
strategy:
|
||||
matrix:
|
||||
Architecture: ['x64', 'ARM64']
|
||||
# Always run this job.
|
||||
if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch'
|
||||
uses: ./.github/workflows/reusable-build.yml
|
||||
with:
|
||||
ref: ${{ github.ref }}
|
||||
repository: ${{ github.repository }}
|
||||
build_artifact: Build-x64-onebranch
|
||||
build_artifact: Build-${{ matrix.Architecture }}-onebranch
|
||||
generate_release_package: true
|
||||
build_msi: true
|
||||
build_nuget: true
|
||||
configurations: '["NativeOnlyDebug", "NativeOnlyRelease"]'
|
||||
build_options: /p:BuildOneBranch='True' /t:tools\onebranch
|
||||
build_options: /p:BuildOneBranch='True' /t:tools\onebranch /t:installer\ebpf-for-windows
|
||||
solution_file: "ebpf-for-windows.sln"
|
||||
architecture: ${{ matrix.Architecture }}
|
||||
download_demo_repository: false
|
||||
|
||||
# Perform the native-only build.
|
||||
regular_native-only:
|
||||
|
|
|
@ -53,6 +53,14 @@ on:
|
|||
required: false
|
||||
type: string
|
||||
default: 'ebpf-for-windows.sln'
|
||||
architecture:
|
||||
required: false
|
||||
type: string
|
||||
default: 'x64'
|
||||
download_demo_repository:
|
||||
required: false
|
||||
type: boolean
|
||||
default: true
|
||||
outputs:
|
||||
should_skip:
|
||||
description: 'Whether build was skipped due to duplicate action.'
|
||||
|
@ -82,7 +90,7 @@ jobs:
|
|||
SOLUTION_FILE_PATH: ${{inputs.solution_file}}
|
||||
BUILD_ARTIFACT_NAME: ${{inputs.build_artifact}}
|
||||
BUILD_CONFIGURATION: ${{matrix.configurations}}
|
||||
BUILD_PLATFORM: x64
|
||||
BUILD_PLATFORM: ${{inputs.architecture}}
|
||||
BUILD_OPTIONS: ${{inputs.build_options}}
|
||||
CXX_FLAGS: ${{inputs.cxx_flags}}
|
||||
LD_FLAGS: ${{inputs.ld_flags}}
|
||||
|
@ -161,7 +169,7 @@ jobs:
|
|||
cache-name: cache-verifier-project
|
||||
with:
|
||||
path: external/ebpf-verifier/build
|
||||
key: ${{ runner.os }}-${{env.BUILD_PLATFORM}}-${{env.BUILD_CONFIGURATION}}-${{env.BUILD_ARTIFACT_NAME}}-${{ hashFiles('.git/modules/external/ebpf-verifier/HEAD') }}-${{ hashFiles('external/Directory.Build.props')}}-${{env.msvc_tools_version}}
|
||||
key: ${{ runner.os }}-${{env.BUILD_PLATFORM}}-${{env.BUILD_CONFIGURATION}}-${{env.BUILD_ARTIFACT_NAME}}-${{ hashFiles('.git/modules/external/ebpf-verifier/HEAD') }}-${{ hashFiles('external/Directory.Build.props')}}-${{env.msvc_tools_version}}-${{ hashFiles('scripts/initialize_ebpf_repo.ps1')}}
|
||||
|
||||
- name: Configuring repo for first build
|
||||
if: steps.skip_check.outputs.should_skip != 'true'
|
||||
|
@ -170,7 +178,7 @@ jobs:
|
|||
CXXFLAGS: /ZH:SHA_256 ${{env.CXX_FLAGS}}
|
||||
LDFLAGS: ${{env.LD_FLAGS}}
|
||||
run: |
|
||||
.\scripts\initialize_ebpf_repo.ps1
|
||||
.\scripts\initialize_ebpf_repo.ps1 ${{env.BUILD_PLATFORM}}
|
||||
|
||||
- name: Build
|
||||
if: steps.skip_check.outputs.should_skip != 'true'
|
||||
|
@ -197,12 +205,12 @@ jobs:
|
|||
copy "${{env.msvc_tools_path}}\bin\Hostx64\x64\clang*" .
|
||||
|
||||
- name: Download demo Debug repository
|
||||
if: steps.skip_check.outputs.should_skip != 'true' && (matrix.configurations == 'Debug' || matrix.configurations == 'NativeOnlyDebug')
|
||||
if: steps.skip_check.outputs.should_skip != 'true' && inputs.download_demo_repository == true && (matrix.configurations == 'Debug' || matrix.configurations == 'NativeOnlyDebug')
|
||||
working-directory: ${{env.GITHUB_WORKSPACE}}
|
||||
run: Invoke-WebRequest https://github.com/microsoft/ebpf-for-windows-demo/releases/download/v0.0.2/${{env.BUILD_PLATFORM}}-Debug-cilium-xdp.zip -OutFile x64-${{env.BUILD_CONFIGURATION}}-cilium-xdp.zip
|
||||
|
||||
- name: Download demo Release repository
|
||||
if: steps.skip_check.outputs.should_skip != 'true' && (matrix.configurations == 'Release' || matrix.configurations == 'NativeOnlyRelease')
|
||||
if: steps.skip_check.outputs.should_skip != 'true' && inputs.download_demo_repository == true && (matrix.configurations == 'Release' || matrix.configurations == 'NativeOnlyRelease')
|
||||
working-directory: ${{env.GITHUB_WORKSPACE}}
|
||||
run: Invoke-WebRequest https://github.com/microsoft/ebpf-for-windows-demo/releases/download/v0.0.2/${{env.BUILD_PLATFORM}}-Release-cilium-xdp.zip -OutFile x64-${{env.BUILD_CONFIGURATION}}-cilium-xdp.zip
|
||||
|
||||
|
@ -215,7 +223,7 @@ jobs:
|
|||
Invoke-WebRequest https://github.com/microsoft/bpf_performance/releases/download/v0.0.6/build-Release-windows-2022.zip -OutFile bpf_performance.zip
|
||||
|
||||
- name: Extract artifacts to build path
|
||||
if: steps.skip_check.outputs.should_skip != 'true' && matrix.configurations != 'FuzzerDebug'
|
||||
if: steps.skip_check.outputs.should_skip != 'true' && inputs.download_demo_repository == true && matrix.configurations != 'FuzzerDebug'
|
||||
working-directory: ${{env.GITHUB_WORKSPACE}}
|
||||
run: |
|
||||
cd ${{github.workspace}}/${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}}
|
||||
|
@ -243,12 +251,12 @@ jobs:
|
|||
path: ${{github.workspace}}/${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}}/ebpf-for-windows.msi
|
||||
|
||||
- name: Build the NuGet package
|
||||
if: inputs.build_nuget == true && matrix.configurations == 'Release' && steps.skip_check.outputs.should_skip != 'true'
|
||||
if: inputs.build_nuget == true && (matrix.configurations == 'Release' || matrix.configurations == 'NativeOnlyRelease') && steps.skip_check.outputs.should_skip != 'true'
|
||||
working-directory: ${{env.GITHUB_WORKSPACE}}
|
||||
run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=${{env.BUILD_PLATFORM}} ${{env.SOLUTION_FILE_PATH}} ${{env.BUILD_OPTIONS}} /t:tools\nuget
|
||||
|
||||
- name: Upload the NuGet package
|
||||
if: inputs.build_nuget == true && matrix.configurations == 'Release' && steps.skip_check.outputs.should_skip != 'true'
|
||||
if: inputs.build_nuget == true && (matrix.configurations == 'Release' || matrix.configurations == 'NativeOnlyRelease') && steps.skip_check.outputs.should_skip != 'true'
|
||||
uses: actions/upload-artifact@604373da6381bf24206979c74d06a550515601b9
|
||||
with:
|
||||
name: ebpf-for-windows - NuGet package (${{inputs.build_artifact}}_${{env.BUILD_CONFIGURATION}})
|
||||
|
|
|
@ -31,6 +31,26 @@
|
|||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|ARM64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="NativeOnlyDebug|ARM64">
|
||||
<Configuration>NativeOnlyDebug</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="FuzzerDebug|ARM64">
|
||||
<Configuration>FuzzerDebug</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="NativeOnlyRelease|ARM64">
|
||||
<Configuration>NativeOnlyRelease</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|ARM64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition="'$(Analysis)'=='True'">
|
||||
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||
|
@ -44,10 +64,11 @@
|
|||
<DisableJIT>true</DisableJIT>
|
||||
<DisableInterpreter>true</DisableInterpreter>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Release' Or '$(Configuration)'=='NativeOnlyRelease'">
|
||||
<!-- Libsancov.lib not supported on arm64 -->
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64' Or '$(Configuration)|$(Platform)'=='NativeOnlyRelease|x64'">
|
||||
<FuzzerLibs>libsancov.lib;clang_rt.fuzzer_MD-x86_64.lib</FuzzerLibs>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Debug' Or '$(Configuration)'=='FuzzerDebug' Or '$(Configuration)'=='NativeOnlyDebug'">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64' Or '$(Configuration)|$(Platform)'=='FuzzerDebug|x64' Or '$(Configuration)|$(Platform)'=='NativeOnlyDebug|x64'">
|
||||
<FuzzerLibs>libsancov.lib;clang_rt.fuzzer_MDd-x86_64.lib</FuzzerLibs>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Fuzzer)'=='Release|True'">
|
||||
|
@ -81,6 +102,7 @@
|
|||
<Link>
|
||||
<CETCompat Condition="'$(Platform)'=='x64'">true</CETCompat>
|
||||
<AdditionalLibraryDirectories Condition="'$(Platform)'=='x64'">$(VC_LibraryPath_VC_x64_Desktop);%(Link.AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalLibraryDirectories Condition="'$(Platform)'=='ARM64'">$(VC_LibraryPath_VC_ARM64_Desktop);%(Link.AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(DisableJIT)'=='True'">
|
||||
|
@ -123,4 +145,17 @@
|
|||
<PreprocessorDefinitions>_AMD64_;_WIN32_WINNT=0x0a00;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_X86_;_WIN32_WINNT=0x0a00;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Platform)'=='ARM64'">
|
||||
<ClCompile>
|
||||
<!-- Set the _ARM64_ as it is required by winnt.h for correct compilation rather than the standard _M_ARM64 -->
|
||||
<PreprocessorDefinitions>_ARM64_;_WIN32_WINNT=0x0a00;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<!-- Set the option to emit both armv8.0 atomics and armv8.1 atomics with processor detection to select the best performing one.-->
|
||||
<AdditionalOptions>/d2overrideInterlockedIntrinsArm64 %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
</Project>
|
||||
|
|
2664
ebpf-for-windows.sln
2664
ebpf-for-windows.sln
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -7,7 +7,8 @@ SPDX-License-Identifier: MIT
|
|||
<?define UpgradeCode="B6BCACB1-C872-4159-ABCB-43A50668056C"?>
|
||||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:ui="http://schemas.microsoft.com/wix/UIExtension" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
|
||||
<Product Id="$(var.ProductVersion)" Name="eBPF for Windows" Language="1033" Version="$(var.EbpfVersion)" Manufacturer="Microsoft" UpgradeCode="$(var.UpgradeCode)">
|
||||
<Package Description="eBPF for Windows" InstallerVersion="301" Compressed="yes" InstallScope="perMachine" Manufacturer="Microsoft" Platform="x64" />
|
||||
<!-- Platform should be $(var.Platform) but the current installer doesn't support ARM64. Fortunately ARM64 can emulate x64, so setting it to x64 works. -->
|
||||
<Package Description="eBPF for Windows" InstallerVersion="301" Compressed="yes" InstallScope="perMachine" Manufacturer="Microsoft" Platform="x64"/>
|
||||
<MajorUpgrade AllowSameVersionUpgrades="yes"
|
||||
Disallow="yes" DisallowUpgradeErrorMessage="An older version of [ProductName] is already installed. Please remove it first."
|
||||
AllowDowngrades="no" DowngradeErrorMessage="A newer version of [ProductName] is already installed. Please remove it first." Schedule="afterInstallFinalize" />
|
||||
|
@ -117,31 +118,31 @@ SPDX-License-Identifier: MIT
|
|||
<?if $(var.IncludeVCRedist) = True ?>
|
||||
<ComponentGroup Id="VCRedist" Directory="INSTALLFOLDER">
|
||||
<Component Id="concrt140" Guid="{BA96F793-1D16-4277-B12B-7588BC2E647A}">
|
||||
<File Id="concrt140.dll" Name="concrt140.dll" DiskId="1" KeyPath="yes" Source="$(var.SolutionDir)x64\$(var.Configuration)\concrt140.dll" />
|
||||
<File Id="concrt140.dll" Name="concrt140.dll" DiskId="1" KeyPath="yes" Source="$(var.SolutionDir)$(var.Platform)\$(var.Configuration)\concrt140.dll" />
|
||||
</Component>
|
||||
<Component Id="msvcp140" Guid="{225C690D-C9B9-4F6C-B422-6579380E3A41}">
|
||||
<File Id="msvcp140.dll" Name="msvcp140.dll" DiskId="1" KeyPath="yes" Source="$(var.SolutionDir)x64\$(var.Configuration)\msvcp140.dll" />
|
||||
<File Id="msvcp140.dll" Name="msvcp140.dll" DiskId="1" KeyPath="yes" Source="$(var.SolutionDir)$(var.Platform)\$(var.Configuration)\msvcp140.dll" />
|
||||
</Component>
|
||||
<Component Id="msvcp140_1" Guid="{32C5D7C0-43CA-469E-A712-5A7ED0C18F68}">
|
||||
<File Id="msvcp140_1.dll" Name="msvcp140_1.dll" DiskId="1" KeyPath="yes" Source="$(var.SolutionDir)x64\$(var.Configuration)\msvcp140_1.dll" />
|
||||
<File Id="msvcp140_1.dll" Name="msvcp140_1.dll" DiskId="1" KeyPath="yes" Source="$(var.SolutionDir)$(var.Platform)\$(var.Configuration)\msvcp140_1.dll" />
|
||||
</Component>
|
||||
<Component Id="msvcp140_2" Guid="{CD0CB411-69A8-427F-B775-B1C0BB269D2A}">
|
||||
<File Id="msvcp140_2.dll" Name="msvcp140_2.dll" DiskId="1" KeyPath="yes" Source="$(var.SolutionDir)x64\$(var.Configuration)\msvcp140_2.dll" />
|
||||
<File Id="msvcp140_2.dll" Name="msvcp140_2.dll" DiskId="1" KeyPath="yes" Source="$(var.SolutionDir)$(var.Platform)\$(var.Configuration)\msvcp140_2.dll" />
|
||||
</Component>
|
||||
<Component Id="msvcp140_atomic_wait" Guid="{EDD2FCE1-0A0C-4DF0-A935-6A917BEC8FD2}">
|
||||
<File Id="msvcp140_atomic_wait.dll" Name="msvcp140_atomic_wait.dll" DiskId="1" KeyPath="yes" Source="$(var.SolutionDir)x64\$(var.Configuration)\msvcp140_atomic_wait.dll" />
|
||||
<File Id="msvcp140_atomic_wait.dll" Name="msvcp140_atomic_wait.dll" DiskId="1" KeyPath="yes" Source="$(var.SolutionDir)$(var.Platform)\$(var.Configuration)\msvcp140_atomic_wait.dll" />
|
||||
</Component>
|
||||
<Component Id="msvcp140_codecvt_ids" Guid="{ED0E8435-4D52-4801-81A5-E4EF0DFA9CA7}">
|
||||
<File Id="msvcp140_codecvt_ids.dll" Name="msvcp140_codecvt_ids.dll" DiskId="1" KeyPath="yes" Source="$(var.SolutionDir)x64\$(var.Configuration)\msvcp140_codecvt_ids.dll" />
|
||||
<File Id="msvcp140_codecvt_ids.dll" Name="msvcp140_codecvt_ids.dll" DiskId="1" KeyPath="yes" Source="$(var.SolutionDir)$(var.Platform)\$(var.Configuration)\msvcp140_codecvt_ids.dll" />
|
||||
</Component>
|
||||
<Component Id="vccorlib140" Guid="{D1B5ADB1-10BB-491C-B10E-8B5445D71484}">
|
||||
<File Id="vccorlib140.dll" Name="vccorlib140.dll" DiskId="1" KeyPath="yes" Source="$(var.SolutionDir)x64\$(var.Configuration)\vccorlib140.dll" />
|
||||
<File Id="vccorlib140.dll" Name="vccorlib140.dll" DiskId="1" KeyPath="yes" Source="$(var.SolutionDir)$(var.Platform)\$(var.Configuration)\vccorlib140.dll" />
|
||||
</Component>
|
||||
<Component Id="vcruntime140" Guid="{96C01CAE-A895-463D-B090-7E15DD03724E}">
|
||||
<File Id="vcruntime140.dll" Name="vcruntime140.dll" DiskId="1" KeyPath="yes" Source="$(var.SolutionDir)x64\$(var.Configuration)\vcruntime140.dll" />
|
||||
<File Id="vcruntime140.dll" Name="vcruntime140.dll" DiskId="1" KeyPath="yes" Source="$(var.SolutionDir)$(var.Platform)\$(var.Configuration)\vcruntime140.dll" />
|
||||
</Component>
|
||||
<Component Id="vcruntime140_1" Guid="{2EC40012-1B68-4DAB-91B9-6B4190B4EB6D}">
|
||||
<File Id="vcruntime140_1.dll" Name="vcruntime140_1.dll" DiskId="1" KeyPath="yes" Source="$(var.SolutionDir)x64\$(var.Configuration)\vcruntime140_1.dll" />
|
||||
<File Id="vcruntime140_1.dll" Name="vcruntime140_1.dll" DiskId="1" KeyPath="yes" Source="$(var.SolutionDir)$(var.Platform)\$(var.Configuration)\vcruntime140_1.dll" />
|
||||
</Component>
|
||||
</ComponentGroup>
|
||||
<?endif?>
|
||||
|
|
|
@ -14,7 +14,7 @@ SPDX-License-Identifier: MIT
|
|||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<OutputName>ebpf-for-windows</OutputName>
|
||||
<OutputType>Package</OutputType>
|
||||
<InstallerPlatform>x64</InstallerPlatform>
|
||||
<InstallerPlatform>$(Platform)</InstallerPlatform>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
|
@ -49,6 +49,23 @@ SPDX-License-Identifier: MIT
|
|||
<SuppressValidation>True</SuppressValidation>
|
||||
<DefineConstants>$(DefineConstants);IncludeVCRedist=True</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<!-- ARM64 support for JIT is not yet implemeted, so only declare a NativeOnly version of the installer. -->
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'NativeOnlyDebug|ARM64' ">
|
||||
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\</OutputPath>
|
||||
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
|
||||
<DefineConstants Condition=" '$(ReleaseJIT)' == 'True' ">$(DefineConstants);IncludeJIT=True</DefineConstants>
|
||||
<DefineConstants Condition=" '$(ReleaseJIT)' == 'False' OR '$(ReleaseJIT)' == '' ">$(DefineConstants);IncludeJIT=False</DefineConstants>
|
||||
<DefineConstants>$(DefineConstants);Debug;IncludeVCRedist=False</DefineConstants>
|
||||
<SuppressValidation>True</SuppressValidation>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'NativeOnlyRelease|ARM64' ">
|
||||
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\</OutputPath>
|
||||
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
|
||||
<DefineConstants Condition=" '$(ReleaseJIT)' == 'True' ">$(DefineConstants);IncludeJIT=True</DefineConstants>
|
||||
<DefineConstants Condition=" '$(ReleaseJIT)' == 'False' OR '$(ReleaseJIT)' == '' ">$(DefineConstants);IncludeJIT=False</DefineConstants>
|
||||
<DefineConstants>$(DefineConstants);IncludeVCRedist=True</DefineConstants>
|
||||
<SuppressValidation>True</SuppressValidation>
|
||||
</PropertyGroup>
|
||||
<!-- In accordance to what defined in sample.vcxproj, the MSI build is disabled for the 'Analysis' CI/CD build, as it does not generate the *.o artifacts. -->
|
||||
<ItemGroup Condition="'$(Analysis)'==''">
|
||||
<Compile Include="Product.wxs" />
|
||||
|
|
|
@ -89,6 +89,37 @@ ubpf_jit_update_helper_x86_64(
|
|||
return false;
|
||||
}
|
||||
|
||||
// Thunk out JIT related calls.
|
||||
// Workaround until https://github.com/iovisor/ubpf/issues/185 is fixed.
|
||||
struct ubpf_jit_result
|
||||
ubpf_translate_arm64(struct ubpf_vm* vm, uint8_t* buffer, size_t* size, enum JitMode jit_mode)
|
||||
{
|
||||
__fastfail(0);
|
||||
struct ubpf_jit_result result = {0};
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
ubpf_jit_update_dispatcher_arm64(
|
||||
struct ubpf_vm* vm, external_function_dispatcher_t new_dispatcher, uint8_t* buffer, size_t size, uint32_t offset)
|
||||
{
|
||||
__fastfail(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
ubpf_jit_update_helper_arm64(
|
||||
struct ubpf_vm* vm,
|
||||
extended_external_helper_t new_helper,
|
||||
unsigned int idx,
|
||||
uint8_t* buffer,
|
||||
size_t size,
|
||||
uint32_t offset)
|
||||
{
|
||||
__fastfail(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 28159) // Don't use KeBugCheck
|
||||
void __cdecl abort(void) { KeBugCheck(PAGE_FAULT_IN_NONPAGED_AREA); }
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
# Copyright (c) eBPF for Windows contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# Accept architecture as a parameter (e.g., X64, ARM64)
|
||||
param (
|
||||
[parameter(Mandatory = $false)][string] $Architecture = "x64"
|
||||
)
|
||||
|
||||
# This script assumes it is called from the root of the repository, but it can be called from any directory.
|
||||
# To handle this, we first get the directory where the script is located and then change the parent directory to the root of the repository.
|
||||
|
||||
|
@ -11,11 +16,12 @@ $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
|
|||
Set-Location $scriptPath\..
|
||||
|
||||
# Define the commands to run
|
||||
$cmakeCommonArgs = "-G 'Visual Studio 17 2022' -A $Architecture"
|
||||
$commands = @(
|
||||
"git submodule update --init --recursive",
|
||||
"cmake -G 'Visual Studio 17 2022' -S external\ebpf-verifier -B external\ebpf-verifier\build",
|
||||
"cmake -G 'Visual Studio 17 2022' -S external\catch2 -B external\catch2\build -DBUILD_TESTING=OFF",
|
||||
"cmake -G 'Visual Studio 17 2022' -S external\ubpf -B external\ubpf\build",
|
||||
"cmake $cmakeCommonArgs -S external\ebpf-verifier -B external\ebpf-verifier\build",
|
||||
"cmake $cmakeCommonArgs -S external\catch2 -B external\catch2\build -DBUILD_TESTING=OFF",
|
||||
"cmake $cmakeCommonArgs -S external\ubpf -B external\ubpf\build",
|
||||
"nuget restore ebpf-for-windows.sln"
|
||||
)
|
||||
|
||||
|
|
|
@ -12,42 +12,62 @@ Set-Location $scriptPath\..\..
|
|||
$OneBranchArch = $env:ONEBRANCH_ARCH
|
||||
$OneBranchConfig = $env:ONEBRANCH_CONFIG
|
||||
|
||||
# Copy the signed binaries to the output directory
|
||||
if ($OneBranchConfig -eq "NativeOnlyDebug" -and $OneBranchArch -eq "x64")
|
||||
{
|
||||
xcopy /y build\bin\x64_NativeOnlyDebug .\x64\NativeOnlyDebug
|
||||
Get-ChildItem -Path .\build\bin\x64_NativeOnlyDebug -Recurse | Remove-Item -Force -Recurse
|
||||
function CopySignedBinaries {
|
||||
param (
|
||||
[string]$Config,
|
||||
[string]$Arch
|
||||
)
|
||||
xcopy /y "build\bin\$Arch\_$Config" ".\$Arch\$Config"
|
||||
Get-ChildItem -Path "build\bin\$Arch\_$Config" -Recurse | Remove-Item -Force -Recurse
|
||||
}
|
||||
elseif ($OneBranchConfig -eq "NativeOnlyRelease" -and $OneBranchArch -eq "x64")
|
||||
|
||||
function CopyPackages {
|
||||
param (
|
||||
[string]$Config,
|
||||
[string]$Arch
|
||||
)
|
||||
xcopy /y ".\$Arch\$Config\*.nupkg" "build\bin\$Arch\_$Config"
|
||||
xcopy /y ".\$Arch\$Config\*.msi" "build\bin\$Arch\_$Config"
|
||||
}
|
||||
|
||||
if ($OneBranchConfig -eq "NativeOnlyDebug" -or $OneBranchConfig -eq "NativeOnlyRelease")
|
||||
{
|
||||
xcopy /y build\bin\x64_NativeOnlyRelease .\x64\NativeOnlyRelease
|
||||
Get-ChildItem -Path .\build\bin\x64_NativeOnlyRelease -Recurse | Remove-Item -Force -Recurse
|
||||
if ($OneBranchArch -eq "x64" -or $OneBranchArch -eq "arm64")
|
||||
{
|
||||
CopySignedBinaries -Config $OneBranchConfig -Arch $OneBranchArch
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ("Architecture $OneBranchArch is not supported.")
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ("Configuration $OneBranchConfig|$OneBranchArch is not supported.")
|
||||
throw ("Configuration $OneBranchConfig is not supported.")
|
||||
}
|
||||
|
||||
Import-Module "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
|
||||
Enter-VsDevShell -VsInstallPath "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" -DevCmdArguments "-arch=x64 -host_arch=x64"
|
||||
Enter-VsDevShell -VsInstallPath "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" -DevCmdArguments "-arch=$OneBranchArch -host_arch=x64"
|
||||
Set-Location $scriptPath\..\..
|
||||
$SolutionDir = Get-Location
|
||||
msbuild /p:SolutionDir=$SolutionDir\ /p:Configuration=$OneBranchConfig /p:Platform=$OneBranchArch /p:BuildProjectReferences=false .\tools\nuget\nuget.vcxproj
|
||||
msbuild /p:SolutionDir=$SolutionDir\ /p:Configuration=$OneBranchConfig /p:Platform=$OneBranchArch /p:BuildProjectReferences=false .\tools\redist-package\redist-package.vcxproj
|
||||
msbuild /p:SolutionDir=$SolutionDir\ /p:Configuration=$OneBranchConfig /p:Platform=$OneBranchArch /p:BuildProjectReferences=false .\installer\ebpf-for-windows.wixproj
|
||||
|
||||
# After building the packages
|
||||
# Copy the nupkg and msi to the output directory
|
||||
if ($OneBranchConfig -eq "NativeOnlyDebug" -and $OneBranchArch -eq "x64")
|
||||
if ($OneBranchConfig -eq "NativeOnlyDebug" -or $OneBranchConfig -eq "NativeOnlyRelease")
|
||||
{
|
||||
xcopy /y .\x64\NativeOnlyDebug\*.nupkg .\build\bin\x64_NativeOnlyDebug
|
||||
xcopy /y .\x64\NativeOnlyDebug\*.msi .\build\bin\x64_NativeOnlyDebug
|
||||
}
|
||||
elseif ($OneBranchConfig -eq "NativeOnlyRelease" -and $OneBranchArch -eq "x64")
|
||||
{
|
||||
xcopy /y .\x64\NativeOnlyRelease\*.nupkg .\build\bin\x64_NativeOnlyRelease
|
||||
xcopy /y .\x64\NativeOnlyRelease\*.msi .\build\bin\x64_NativeOnlyRelease
|
||||
if ($OneBranchArch -eq "x64" -or $OneBranchArch -eq "arm64")
|
||||
{
|
||||
CopyPackages -Config $OneBranchConfig -Arch $OneBranchArch
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ("Architecture $OneBranchArch is not supported.")
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ("Configuration $OneBranchConfig|$OneBranchArch is not supported.")
|
||||
}
|
||||
throw ("Configuration $OneBranchConfig is not supported.")
|
||||
}
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
# Copyright (c) eBPF for Windows contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
$OneBranchArch = if ($env:ONEBRANCH_ARCH) { $env:ONEBRANCH_ARCH } else { "x64" }
|
||||
|
||||
# Get the path where this script is located
|
||||
$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
|
||||
|
||||
# Change the parent directory for the script directory
|
||||
Set-Location $scriptPath\..\..
|
||||
|
||||
.\scripts\initialize_ebpf_repo.ps1
|
||||
try {
|
||||
.\scripts\initialize_ebpf_repo.ps1 -Architecture $OneBranchArch
|
||||
}
|
||||
catch {
|
||||
throw "Failed to initialize the eBPF for Windows repository."
|
||||
}
|
||||
|
||||
Get-ChildItem -Path ./external -Filter *.dll -Recurse | Remove-Item
|
||||
|
|
|
@ -282,6 +282,10 @@ popd
|
|||
powershell -NonInteractive -ExecutionPolicy Unrestricted $(SolutionDir)scripts\generate-commitid.ps1 $(SolutionDir)\include
|
||||
copy "$(VC_DebugCppRuntimeFilesPath_x64)\Microsoft.VC143.DebugCRT\*" "$(OutDir)"
|
||||
copy "$(UniversalDebugCRT_ExecutablePath_x64)\ucrtbased.dll" "$(OutDir)"</Command>
|
||||
<Command Condition="'$(Platform)'=='ARM64'">powershell -NonInteractive -ExecutionPolicy Unrestricted $(SolutionDir)scripts\copy_pre_commit.ps1 $(SolutionDir)scripts\pre-commit
|
||||
powershell -NonInteractive -ExecutionPolicy Unrestricted $(SolutionDir)scripts\generate-commitid.ps1 $(SolutionDir)\include
|
||||
copy "$(VC_DebugCppRuntimeFilesPath_ARM64)\Microsoft.VC143.DebugCRT\*" "$(OutDir)"
|
||||
copy "$(UniversalDebugCRT_ExecutablePath_ARM64)\ucrtbased.dll" "$(OutDir)"</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='FuzzerDebug'">
|
||||
|
@ -298,6 +302,10 @@ copy "$(UniversalDebugCRT_ExecutablePath_x64)\ucrtbased.dll" "$(OutDir)"</Comman
|
|||
powershell -NonInteractive -ExecutionPolicy Unrestricted $(SolutionDir)scripts\generate-commitid.ps1 $(SolutionDir)\include
|
||||
copy "$(VC_DebugCppRuntimeFilesPath_x64)\Microsoft.VC143.DebugCRT\*" "$(OutDir)"
|
||||
copy "$(UniversalDebugCRT_ExecutablePath_x64)\ucrtbased.dll" "$(OutDir)"</Command>
|
||||
<Command Condition="'$(Platform)'=='ARM64'">powershell -NonInteractive -ExecutionPolicy Unrestricted $(SolutionDir)scripts\copy_pre_commit.ps1 $(SolutionDir)scripts\pre-commit
|
||||
powershell -NonInteractive -ExecutionPolicy Unrestricted $(SolutionDir)scripts\generate-commitid.ps1 $(SolutionDir)\include
|
||||
copy "$(VC_DebugCppRuntimeFilesPath_ARM64)\Microsoft.VC143.DebugCRT\*" "$(OutDir)"
|
||||
copy "$(UniversalDebugCRT_ExecutablePath_ARM64)\ucrtbased.dll" "$(OutDir)"</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='NativeOnlyDebug'">
|
||||
|
@ -314,6 +322,10 @@ copy "$(UniversalDebugCRT_ExecutablePath_x64)\ucrtbased.dll" "$(OutDir)"</Comman
|
|||
powershell -NonInteractive -ExecutionPolicy Unrestricted $(SolutionDir)scripts\generate-commitid.ps1 $(SolutionDir)\include
|
||||
copy "$(VC_DebugCppRuntimeFilesPath_x64)\Microsoft.VC143.DebugCRT\*" "$(OutDir)"
|
||||
copy "$(UniversalDebugCRT_ExecutablePath_x64)\ucrtbased.dll" "$(OutDir)"</Command>
|
||||
<Command Condition="'$(Platform)'=='ARM64'">powershell -NonInteractive -ExecutionPolicy Unrestricted $(SolutionDir)scripts\copy_pre_commit.ps1 $(SolutionDir)scripts\pre-commit
|
||||
powershell -NonInteractive -ExecutionPolicy Unrestricted $(SolutionDir)scripts\generate-commitid.ps1 $(SolutionDir)\include
|
||||
copy "$(VC_DebugCppRuntimeFilesPath_ARM64)\Microsoft.VC143.DebugCRT\*" "$(OutDir)"
|
||||
copy "$(UniversalDebugCRT_ExecutablePath_ARM64)\ucrtbased.dll" "$(OutDir)"</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||
|
@ -331,6 +343,9 @@ copy "$(UniversalDebugCRT_ExecutablePath_x64)\ucrtbased.dll" "$(OutDir)"</Comman
|
|||
<Command Condition="'$(Platform)'=='x64'">powershell -NonInteractive -ExecutionPolicy Unrestricted $(SolutionDir)scripts\copy_pre_commit.ps1 $(SolutionDir)scripts\pre-commit
|
||||
powershell -NonInteractive -ExecutionPolicy Unrestricted $(SolutionDir)scripts\generate-commitid.ps1 $(SolutionDir)\include
|
||||
copy "$(VC_CppRuntimeFilesPath_x64)\Microsoft.VC143.CRT" "$(OutDir)"</Command>
|
||||
<Command Condition="'$(Platform)'=='ARM64'">powershell -NonInteractive -ExecutionPolicy Unrestricted $(SolutionDir)scripts\copy_pre_commit.ps1 $(SolutionDir)scripts\pre-commit
|
||||
powershell -NonInteractive -ExecutionPolicy Unrestricted $(SolutionDir)scripts\generate-commitid.ps1 $(SolutionDir)\include
|
||||
copy "$(VC_CppRuntimeFilesPath_ARM64)\Microsoft.VC143.CRT" "$(OutDir)"</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='NativeOnlyRelease'">
|
||||
|
@ -348,6 +363,9 @@ copy "$(VC_CppRuntimeFilesPath_x64)\Microsoft.VC143.CRT" "$(OutDir)"</Command>
|
|||
<Command Condition="'$(Platform)'=='x64'">powershell -NonInteractive -ExecutionPolicy Unrestricted $(SolutionDir)scripts\copy_pre_commit.ps1 $(SolutionDir)scripts\pre-commit
|
||||
powershell -NonInteractive -ExecutionPolicy Unrestricted $(SolutionDir)scripts\generate-commitid.ps1 $(SolutionDir)\include
|
||||
copy "$(VC_CppRuntimeFilesPath_x64)\Microsoft.VC143.CRT" "$(OutDir)"</Command>
|
||||
<Command Condition="'$(Platform)'=='ARM64'">powershell -NonInteractive -ExecutionPolicy Unrestricted $(SolutionDir)scripts\copy_pre_commit.ps1 $(SolutionDir)scripts\pre-commit
|
||||
powershell -NonInteractive -ExecutionPolicy Unrestricted $(SolutionDir)scripts\generate-commitid.ps1 $(SolutionDir)\include
|
||||
copy "$(VC_CppRuntimeFilesPath_ARM64)\Microsoft.VC143.CRT" "$(OutDir)"</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
|
|
|
@ -224,21 +224,30 @@ TEST_CASE("show sections bpf.sys", "[netsh][sections]")
|
|||
std::string output = _run_netsh_command(handle_ebpf_show_sections, L"bpf.sys", nullptr, nullptr, &result);
|
||||
REQUIRE(result == NO_ERROR);
|
||||
|
||||
#if defined(_M_X64) && defined(NDEBUG)
|
||||
const int code_size = 1064;
|
||||
#elif defined(_M_X64) && !defined(NDEBUG)
|
||||
const int code_size = 1768;
|
||||
#elif defined(_M_ARM64) && defined(NDEBUG)
|
||||
const int code_size = 1120;
|
||||
#elif defined(_M_ARM64) && !defined(NDEBUG)
|
||||
const int code_size = 5984;
|
||||
#else
|
||||
#error "Unsupported architecture"
|
||||
#endif
|
||||
|
||||
// Expected output is a format string with the code size filled in.
|
||||
const std::string expected_output = "\n"
|
||||
" Size\n"
|
||||
" Section Program Type (bytes)\n"
|
||||
"==================== ====================== ========= =======\n"
|
||||
#if defined(NDEBUG)
|
||||
" .text func bind 1064\n"
|
||||
#else
|
||||
" .text func bind 1768\n"
|
||||
#endif
|
||||
" .text func bind {:7}\n"
|
||||
"\n"
|
||||
" Key Value Max\n"
|
||||
" Map Type Size Size Entries Name\n"
|
||||
"================== ==== ===== ======= ========\n";
|
||||
|
||||
REQUIRE(output == expected_output);
|
||||
REQUIRE(output == std::vformat(expected_output, std::make_format_args(code_size)));
|
||||
}
|
||||
|
||||
// Test a DLL with multiple maps in the map section.
|
||||
|
@ -250,15 +259,24 @@ TEST_CASE("show sections map_reuse_um.dll", "[netsh][sections]")
|
|||
int result;
|
||||
std::string output = _run_netsh_command(handle_ebpf_show_sections, L"map_reuse_um.dll", nullptr, nullptr, &result);
|
||||
REQUIRE(result == NO_ERROR);
|
||||
|
||||
#if defined(_M_X64) && defined(NDEBUG)
|
||||
const int code_size = 311;
|
||||
#elif defined(_M_X64) && !defined(NDEBUG)
|
||||
const int code_size = 1114;
|
||||
#elif defined(_M_ARM64) && defined(NDEBUG)
|
||||
const int code_size = 316;
|
||||
#elif defined(_M_ARM64) && !defined(NDEBUG)
|
||||
const int code_size = 1020;
|
||||
#else
|
||||
#error "Unsupported architecture"
|
||||
#endif
|
||||
|
||||
const std::string expected_output = "\n"
|
||||
" Size\n"
|
||||
" Section Program Type (bytes)\n"
|
||||
"==================== ====================== ========= =======\n"
|
||||
#if defined(NDEBUG)
|
||||
" sample_ext lookup_update sample 311\n"
|
||||
#else
|
||||
" sample_ext lookup_update sample 1114\n"
|
||||
#endif
|
||||
" sample_ext lookup_update sample {:7}\n"
|
||||
"\n"
|
||||
" Key Value Max\n"
|
||||
" Map Type Size Size Entries Name\n"
|
||||
|
@ -267,7 +285,7 @@ TEST_CASE("show sections map_reuse_um.dll", "[netsh][sections]")
|
|||
" array 4 4 1 port_map\n"
|
||||
" array 4 4 1 inner_map\n";
|
||||
|
||||
REQUIRE(output == expected_output);
|
||||
REQUIRE(output == std::vformat(expected_output, std::make_format_args(code_size)));
|
||||
}
|
||||
|
||||
// Test a .dll file with multiple programs.
|
||||
|
@ -281,47 +299,42 @@ TEST_CASE("show sections tail_call_multiple_um.dll", "[netsh][sections]")
|
|||
_run_netsh_command(handle_ebpf_show_sections, L"tail_call_multiple_um.dll", nullptr, nullptr, &result);
|
||||
REQUIRE(result == NO_ERROR);
|
||||
|
||||
#if defined(_M_X64) && defined(NDEBUG)
|
||||
const int code_size_old[] = {73, 6, 73};
|
||||
const int code_size_new[] = {80, 6, 78};
|
||||
#elif defined(_M_X64) && !defined(NDEBUG)
|
||||
const int code_size_old[] = {413, 190, 413};
|
||||
const int code_size_new[] = {426, 190, 426};
|
||||
#elif defined(_M_ARM64) && defined(NDEBUG)
|
||||
const int code_size_old[] = {116, 8, 112};
|
||||
const int code_size_new[] = {116, 8, 112};
|
||||
#elif defined(_M_ARM64) && !defined(NDEBUG)
|
||||
const int code_size_old[] = {400, 184, 400};
|
||||
const int code_size_new[] = {400, 184, 400};
|
||||
#else
|
||||
#error "Unsupported architecture"
|
||||
#endif
|
||||
|
||||
// Issue #3610: Different MSVC versions expect different numbers of bytes for the same program.
|
||||
// As a workaround, check for both the expected outputs.
|
||||
const std::string expected_output_old = "\n"
|
||||
" Size\n"
|
||||
" Section Program Type (bytes)\n"
|
||||
"==================== ====================== ========= =======\n"
|
||||
#if defined(NDEBUG)
|
||||
" sample_ext/0 callee0 sample 73\n"
|
||||
" sample_ext/1 callee1 sample 6\n"
|
||||
" sample_ext caller sample 73\n"
|
||||
#else
|
||||
" sample_ext/0 callee0 sample 413\n"
|
||||
" sample_ext/1 callee1 sample 190\n"
|
||||
" sample_ext caller sample 413\n"
|
||||
#endif
|
||||
"\n"
|
||||
" Key Value Max\n"
|
||||
" Map Type Size Size Entries Name\n"
|
||||
"================== ==== ===== ======= ========\n"
|
||||
" prog_array 4 4 10 map\n";
|
||||
const std::string expected_output = "\n"
|
||||
" Size\n"
|
||||
" Section Program Type (bytes)\n"
|
||||
"==================== ====================== ========= =======\n"
|
||||
" sample_ext/0 callee0 sample {:7}\n"
|
||||
" sample_ext/1 callee1 sample {:7}\n"
|
||||
" sample_ext caller sample {:7}\n"
|
||||
"\n"
|
||||
" Key Value Max\n"
|
||||
" Map Type Size Size Entries Name\n"
|
||||
"================== ==== ===== ======= ========\n"
|
||||
" prog_array 4 4 10 map\n";
|
||||
|
||||
const std::string expected_output_new = "\n"
|
||||
" Size\n"
|
||||
" Section Program Type (bytes)\n"
|
||||
"==================== ====================== ========= =======\n"
|
||||
#if defined(NDEBUG)
|
||||
" sample_ext/0 callee0 sample 80\n"
|
||||
" sample_ext/1 callee1 sample 6\n"
|
||||
" sample_ext caller sample 78\n"
|
||||
#else
|
||||
" sample_ext/0 callee0 sample 426\n"
|
||||
" sample_ext/1 callee1 sample 190\n"
|
||||
" sample_ext caller sample 426\n"
|
||||
#endif
|
||||
"\n"
|
||||
" Key Value Max\n"
|
||||
" Map Type Size Size Entries Name\n"
|
||||
"================== ==== ===== ======= ========\n"
|
||||
" prog_array 4 4 10 map\n";
|
||||
|
||||
REQUIRE((output == expected_output_old || output == expected_output_new));
|
||||
REQUIRE(
|
||||
(output == std::vformat(
|
||||
expected_output, std::make_format_args(code_size_old[0], code_size_old[1], code_size_old[2])) ||
|
||||
output == std::vformat(
|
||||
expected_output, std::make_format_args(code_size_new[0], code_size_new[1], code_size_new[2]))));
|
||||
}
|
||||
|
||||
// Test a .sys file with multiple programs, including ones with long names.
|
||||
|
@ -334,21 +347,27 @@ TEST_CASE("show sections cgroup_sock_addr.sys", "[netsh][sections]")
|
|||
std::string output =
|
||||
_run_netsh_command(handle_ebpf_show_sections, L"cgroup_sock_addr.sys", nullptr, nullptr, &result);
|
||||
REQUIRE(result == NO_ERROR);
|
||||
|
||||
#if defined(_M_X64) && defined(NDEBUG)
|
||||
const int code_size[] = {322, 339, 322, 339};
|
||||
#elif defined(_M_X64) && !defined(NDEBUG)
|
||||
const int code_size[] = {911, 986, 911, 986};
|
||||
#elif defined(_M_ARM64) && defined(NDEBUG)
|
||||
const int code_size[] = {308, 324, 308, 324};
|
||||
#elif defined(_M_ARM64) && !defined(NDEBUG)
|
||||
const int code_size[] = {1044, 1176, 1044, 1176};
|
||||
#else
|
||||
#error "Unsupported architecture"
|
||||
#endif
|
||||
|
||||
const std::string expected_output = "\n"
|
||||
" Size\n"
|
||||
" Section Program Type (bytes)\n"
|
||||
"==================== ====================== ========= =======\n"
|
||||
#if defined(NDEBUG)
|
||||
" cgroup/connect4 authorize_connect4 sock_addr 322\n"
|
||||
" cgroup/connect6 authorize_connect6 sock_addr 339\n"
|
||||
" cgroup/recv_accept4 authorize_recv_accept4 sock_addr 322\n"
|
||||
" cgroup/recv_accept6 authorize_recv_accept6 sock_addr 339\n"
|
||||
#else
|
||||
" cgroup/connect4 authorize_connect4 sock_addr 911\n"
|
||||
" cgroup/connect6 authorize_connect6 sock_addr 986\n"
|
||||
" cgroup/recv_accept4 authorize_recv_accept4 sock_addr 911\n"
|
||||
" cgroup/recv_accept6 authorize_recv_accept6 sock_addr 986\n"
|
||||
#endif
|
||||
" cgroup/connect4 authorize_connect4 sock_addr {:7}\n"
|
||||
" cgroup/connect6 authorize_connect6 sock_addr {:7}\n"
|
||||
" cgroup/recv_accept4 authorize_recv_accept4 sock_addr {:7}\n"
|
||||
" cgroup/recv_accept6 authorize_recv_accept6 sock_addr {:7}\n"
|
||||
"\n"
|
||||
" Key Value Max\n"
|
||||
" Map Type Size Size Entries Name\n"
|
||||
|
@ -356,7 +375,9 @@ TEST_CASE("show sections cgroup_sock_addr.sys", "[netsh][sections]")
|
|||
" hash 56 4 1 egress_connection_policy_map\n"
|
||||
" hash 56 4 1 ingress_connection_policy_map\n"
|
||||
" hash 56 8 1000 socket_cookie_map\n";
|
||||
REQUIRE(output == expected_output);
|
||||
REQUIRE(
|
||||
output ==
|
||||
std::vformat(expected_output, std::make_format_args(code_size[0], code_size[1], code_size[2], code_size[3])));
|
||||
}
|
||||
|
||||
TEST_CASE("show verification nosuchfile.o", "[netsh][verification]")
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
<Configuration>NativeOnlyDebug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="NativeOnlyDebug|ARM64">
|
||||
<Configuration>NativeOnlyDebug</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="FuzzerDebug|x64">
|
||||
<Configuration>FuzzerDebug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
|
@ -25,6 +29,10 @@
|
|||
<Configuration>NativeOnlyRelease</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="NativeOnlyRelease|ARM64">
|
||||
<Configuration>NativeOnlyRelease</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<ReplaceWildcardsInProjectItems>true</ReplaceWildcardsInProjectItems>
|
||||
|
@ -53,6 +61,13 @@
|
|||
<CharacterSet>Unicode</CharacterSet>
|
||||
<KernelConfiguration>Debug</KernelConfiguration>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='NativeOnlyDebug|ARM64'" Label="Configuration">
|
||||
<ConfigurationType>Utility</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<KernelConfiguration>Debug</KernelConfiguration>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='FuzzerDebug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Utility</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
|
@ -74,6 +89,13 @@
|
|||
<CharacterSet>Unicode</CharacterSet>
|
||||
<KernelConfiguration>Release</KernelConfiguration>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='NativeOnlyRelease|ARM64'" Label="Configuration">
|
||||
<ConfigurationType>Utility</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<KernelConfiguration>Release</KernelConfiguration>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
|
@ -85,6 +107,9 @@
|
|||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='NativeOnlyDebug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='NativeOnlyDebug|ARM64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='FuzzerDebug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
|
@ -94,6 +119,9 @@
|
|||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='NativeOnlyRelease|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='NativeOnlyRelease|ARM64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
|
@ -101,6 +129,9 @@
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='NativeOnlyDebug|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='NativeOnlyDebug|ARM64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='FuzzerDebug|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
|
@ -110,6 +141,9 @@
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='NativeOnlyRelease|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='NativeOnlyRelease|ARM64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
@ -130,6 +164,16 @@
|
|||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='NativeOnlyDebug|ARM64'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='FuzzerDebug|x64'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
@ -164,6 +208,18 @@
|
|||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='NativeOnlyRelease|ARM64'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ebpf.h" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -93,4 +93,10 @@
|
|||
<ItemGroup Condition="$(ResourceFile)!=''">
|
||||
<ResourceCompile Include="$(ResourceFile)" />
|
||||
</ItemGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Platform)'=='ARM64'">
|
||||
<ClCompile>
|
||||
<!-- Set the option to emit both armv8.0 atomics and armv8.1 atomics with processor detection to select the best performing one.-->
|
||||
<AdditionalOptions>/d2overrideInterlockedIntrinsArm64 %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
</Project>
|
||||
|
|
|
@ -25,6 +25,18 @@
|
|||
<Configuration>NativeOnlyRelease</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="NativeOnlyDebug|ARM64">
|
||||
<Configuration>NativeOnlyDebug</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="FuzzerDebug|ARM64">
|
||||
<Configuration>FuzzerDebug</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="NativeOnlyRelease|ARM64">
|
||||
<Configuration>NativeOnlyRelease</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="$(FileName)_dll.c" />
|
||||
|
@ -167,10 +179,88 @@
|
|||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='NativeOnlyDebug|ARM64'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>$(IncludeDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4189;4245;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>$(BinDir)bpf2c.exe --bpf $(FileName).o --dll $(FileName)_dll.c $(AdditionalOptions)</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='FuzzerDebug|ARM64'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>$(IncludeDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4189;4245;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>$(BinDir)bpf2c.exe --bpf $(FileName).o --dll $(FileName)_dll.c $(AdditionalOptions)</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='NativeOnlyRelease|ARM64'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>$(IncludeDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4189;4245;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>$(BinDir)bpf2c.exe --bpf $(FileName).o --dll $(FileName)_dll.c $(AdditionalOptions)</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='NativeOnlyRelease'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup Condition="$(ResourceFile)!=''">
|
||||
<ResourceCompile Include="$(ResourceFile)" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Platform)'=='ARM64'">
|
||||
<ClCompile>
|
||||
<!-- Set the option to emit both armv8.0 atomics and armv8.1 atomics with processor detection to select the best performing one.-->
|
||||
<AdditionalOptions>/d2overrideInterlockedIntrinsArm64 %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
</Project>
|
||||
|
|
|
@ -9,9 +9,4 @@
|
|||
<PropertyGroup>
|
||||
<CodeAnalysisRuleSet>$(SolutionDir)external\Analyze.external.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<Link>
|
||||
<AdditionalLibraryDirectories>$(VC_LibraryPath_VC_x64_Desktop);%(Link.AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
</Project>
|
||||
|
|
Загрузка…
Ссылка в новой задаче