mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-19 18:09:47 +01:00
298fd02e4a
9bd3f35003
build: adds switch for disabling random base addresses in MSVC (Ethan Heilman) Pull request description: In m4 builds we have the --disable-hardening switch that can be given in `./configure` to turn off randomized addresses. This PR provides a simple way of turning off randomized addresses in MSVC builds. This PR: * Adds this option the common-init project file so that it can be globally set across the project * Documents this switch in msvc build readme I have run the following test to verify this works I ran the msvc build with `<RandomizedBaseAddress>true</RandomizedBaseAddress>` then checked `bitcoind.exe` and `bitcoin-cli.exe` with `dumpbin.exe`: bitcoind ``` > .\dumpbin.exe /headers src/bitcoind.exe Microsoft (R) COFF/PE Dumper Version 14.16.27045.0 ... OPTIONAL HEADER VALUES 20B magic # (PE32+) 14.28 linker version AE4600 size of code 345C00 size of initialized data 0 size of uninitialized data 6BED74 entry point (00000001406BED74) mainCRTStartup 1000 base of code 140000000 image base (0000000140000000 to 0000000140E2DFFF) 1000 section alignment 200 file alignment 6.00 operating system version 0.00 image version 6.00 subsystem version 0 Win32 version E2E000 size of image 400 size of headers 0 checksum 3 subsystem (Windows CUI) 8160 DLL characteristics High Entropy Virtual Addresses Dynamic base NX compatible Terminal Server Aware ``` bitcoin-cli ``` > .\dumpbin.exe /headers src/bitcoin-cli.exe Microsoft (R) COFF/PE Dumper Version 14.16.27045.0 ... OPTIONAL HEADER VALUES 20B magic # (PE32+) 14.28 linker version 1E3E00 size of code 92C00 size of initialized data 0 size of uninitialized data 104384 entry point (0000000140104384) mainCRTStartup 1000 base of code 140000000 image base (0000000140000000 to 0000000140279FFF) 1000 section alignment 200 file alignment 6.00 operating system version 0.00 image version 6.00 subsystem version 0 Win32 version 27A000 size of image 400 size of headers 0 checksum 3 subsystem (Windows CUI) 8160 DLL characteristics High Entropy Virtual Addresses Dynamic base NX compatible Terminal Server Aware ``` Then I built with `<RandomizedBaseAddress>false</RandomizedBaseAddress>` then checked `bitcoind.exe` and `bitcoin-cli.exe` with `dumpbin.exe` and observed that `Dynamic base` was longer listed in `OPTIONAL HEADER VALUES` bitcoind ``` PS C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64> .\dumpbin.exe /headers C:\Users\e0\Documents\GitHub\bitcoin021noaslr/src/bitcoind.exe Microsoft (R) COFF/PE Dumper Version 14.16.27045.0 ... OPTIONAL HEADER VALUES 20B magic # (PE32+) 14.28 linker version AE4600 size of code 33FE00 size of initialized data 0 size of uninitialized data 6BED74 entry point (00000001406BED74) mainCRTStartup 1000 base of code 140000000 image base (0000000140000000 to 0000000140E27FFF) 1000 section alignment 200 file alignment 6.00 operating system version 0.00 image version 6.00 subsystem version 0 Win32 version E28000 size of image 400 size of headers 0 checksum 3 subsystem (Windows CUI) 8120 DLL characteristics High Entropy Virtual Addresses NX compatible Terminal Server Aware ``` bitcoin-cli ``` > .\dumpbin.exe /headers src/bitcoin-cli.exe Microsoft (R) COFF/PE Dumper Version 14.16.27045.0 ... OPTIONAL HEADER VALUES 20B magic # (PE32+) 14.28 linker version 1E3E00 size of code 90C00 size of initialized data 0 size of uninitialized data 104384 entry point (0000000140104384) mainCRTStartup 1000 base of code 140000000 image base (0000000140000000 to 0000000140277FFF) 1000 section alignment 200 file alignment 6.00 operating system version 0.00 image version 6.00 subsystem version 0 Win32 version 278000 size of image 400 size of headers 0 checksum 3 subsystem (Windows CUI) 8120 DLL characteristics High Entropy Virtual Addresses NX compatible Terminal Server Aware ``` ACKs for top commit: sipsorcery: ACK9bd3f35003
. practicalswift: cr ACK9bd3f35003
: patch looks correct Tree-SHA512: ddffdb4ff8a09c7cfef61c07a5db2a2828e9e3aa795ad8e5a1bf51ab489a68b40f87f6694518c5e0b8858c0fad4f93bb947b052e6b9d5e55eb38e764b746fc02
116 lines
6.0 KiB
XML
116 lines
6.0 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
|
|
<PropertyGroup Label="Globals">
|
|
<VCProjectVersion>16.0</VCProjectVersion>
|
|
<UseNativeEnvironment>true</UseNativeEnvironment>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Label="Vcpkg">
|
|
<VcpkgEnabled>true</VcpkgEnabled>
|
|
<VcpkgEnableManifest>true</VcpkgEnableManifest>
|
|
<VcpkgManifestInstall>true</VcpkgManifestInstall>
|
|
<VcpkgUseStatic>true</VcpkgUseStatic>
|
|
<VcpkgAutoLink>true</VcpkgAutoLink>
|
|
<VcpkgConfiguration>$(Configuration)</VcpkgConfiguration>
|
|
<VcpkgTriplet Condition="'$(Platform)'=='Win32'">x86-windows-static</VcpkgTriplet>
|
|
<VcpkgTriplet Condition="'$(Platform)'=='x64'">x64-windows-static</VcpkgTriplet>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Condition="'$(WindowsTargetPlatformVersion)'=='' and !Exists('$(WindowsSdkDir)\DesignTime\CommonConfiguration\Neutral\Windows.props')">
|
|
<WindowsTargetPlatformVersion_10 Condition="'$(WindowsTargetPlatformVersion_10)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0@ProductVersion)</WindowsTargetPlatformVersion_10>
|
|
<WindowsTargetPlatformVersion_10 Condition="'$(WindowsTargetPlatformVersion_10)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0@ProductVersion)</WindowsTargetPlatformVersion_10>
|
|
<!-- Sometimes the version in the registry has to .0 suffix, and sometimes it doesn't. Check and add it -->
|
|
<WindowsTargetPlatformVersion_10 Condition="'$(WindowsTargetPlatformVersion_10)' != '' and !$(WindowsTargetPlatformVersion_10.EndsWith('.0'))">$(WindowsTargetPlatformVersion_10).0</WindowsTargetPlatformVersion_10>
|
|
<WindowsTargetPlatformVersion>$(WindowsTargetPlatformVersion_10)</WindowsTargetPlatformVersion>
|
|
</PropertyGroup>
|
|
|
|
<ItemGroup Label="ProjectConfigurations">
|
|
<ProjectConfiguration Include="Release|x64">
|
|
<Configuration>Release</Configuration>
|
|
<Platform>x64</Platform>
|
|
</ProjectConfiguration>
|
|
<ProjectConfiguration Include="Debug|x64">
|
|
<Configuration>Debug</Configuration>
|
|
<Platform>x64</Platform>
|
|
</ProjectConfiguration>
|
|
<ProjectConfiguration Include="Release|Win32">
|
|
<Configuration>Release</Configuration>
|
|
<Platform>Win32</Platform>
|
|
</ProjectConfiguration>
|
|
<ProjectConfiguration Include="Debug|Win32">
|
|
<Configuration>Debug</Configuration>
|
|
<Platform>Win32</Platform>
|
|
</ProjectConfiguration>
|
|
</ItemGroup>
|
|
|
|
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
|
|
<LinkIncremental>false</LinkIncremental>
|
|
<UseDebugLibraries>false</UseDebugLibraries>
|
|
<PlatformToolset>v142</PlatformToolset>
|
|
<CharacterSet>Unicode</CharacterSet>
|
|
<GenerateManifest>No</GenerateManifest>
|
|
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
|
<IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
|
|
<LinkIncremental>true</LinkIncremental>
|
|
<UseDebugLibraries>true</UseDebugLibraries>
|
|
<PlatformToolset>v142</PlatformToolset>
|
|
<CharacterSet>Unicode</CharacterSet>
|
|
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
|
<IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
|
</PropertyGroup>
|
|
|
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
|
<ClCompile>
|
|
<Optimization>Disabled</Optimization>
|
|
<WholeProgramOptimization>false</WholeProgramOptimization>
|
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
<SDLCheck>true</SDLCheck>
|
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
|
<DebugInformationFormat>None</DebugInformationFormat>
|
|
</ClCompile>
|
|
<Link>
|
|
<EnableCOMDATFolding>false</EnableCOMDATFolding>
|
|
<OptimizeReferences>false</OptimizeReferences>
|
|
<AdditionalOptions>/LTCG:OFF</AdditionalOptions>
|
|
</Link>
|
|
</ItemDefinitionGroup>
|
|
|
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
|
<ClCompile>
|
|
<Optimization>Disabled</Optimization>
|
|
<WholeProgramOptimization>false</WholeProgramOptimization>
|
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
<SDLCheck>true</SDLCheck>
|
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
|
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
|
|
</ClCompile>
|
|
</ItemDefinitionGroup>
|
|
|
|
<ItemDefinitionGroup>
|
|
<ClCompile>
|
|
<WarningLevel>Level3</WarningLevel>
|
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
<AdditionalOptions>/utf-8 /Zc:__cplusplus /std:c++17 %(AdditionalOptions)</AdditionalOptions>
|
|
<DisableSpecificWarnings>4018;4244;4267;4334;4715;4805;4834</DisableSpecificWarnings>
|
|
<TreatWarningAsError>true</TreatWarningAsError>
|
|
<PreprocessorDefinitions>_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;ZMQ_STATIC;NOMINMAX;WIN32;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_CONSOLE;_WIN32_WINNT=0x0601;_WIN32_IE=0x0501;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
<AdditionalIncludeDirectories>..\..\src;..\..\src\univalue\include;..\..\src\secp256k1\include;..\..\src\leveldb\include;..\..\src\leveldb\helpers\memenv;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
</ClCompile>
|
|
<Link>
|
|
<SubSystem>Console</SubSystem>
|
|
<AdditionalDependencies>Iphlpapi.lib;ws2_32.lib;Shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
<RandomizedBaseAddress>true</RandomizedBaseAddress>
|
|
</Link>
|
|
<Lib>
|
|
<AdditionalOptions>/ignore:4221</AdditionalOptions>
|
|
</Lib>
|
|
</ItemDefinitionGroup>
|
|
<Import Project="common.init.vcxproj.user" Condition="Exists('common.init.vcxproj.user')" />
|
|
</Project>
|