How to disable DYNAMICBASE in msbuild vcxproj

  aslr, bitcoin, c++, linker, msbuild

I would like to pass the linker option /DYNAMICBASE:no to the msvc linker via the vcxproj file which msbuild is using to compile the project.

If someone would like to replicate my failures I am using this vcxproj file to compile bitcoind using this command to build the project:
msbuild bitcoind/bitcoind.vcxproj /p:Platform=x64 /p:Configuration=Release /t:build
While the project builds successfully when run dumpbin headers against the compiled exe I get output containing:

8160 DLL characteristics
  High Entropy Virtual Addresses
  Dynamic base
  NX compatible
  Terminal Server Aware

I have attempted to modify the vcxproj file according to "Passing /highentropyva- to CSC compiler from MSBuild command-line or project file". Note the changes below also include HighEntropyVA as I wanted to verify that it was just an issue with setting the dynamicbase.

  <PropertyGroup Label="Globals">
    <FileAlignment>
      <HighEntropyVA>False</HighEntropyVA>
    </FileAlignment>
    <Link>
      <DynamicBase>False</DynamicBase>
    </Link>
    <ProjectGuid>{D4513DDF-6013-44DC-ADCC-12EAF6D1F038}</ProjectGuid>
  </PropertyGroup>

I also attempted to get this working using an answer to "How to pass linker options to msbuild via command line?". Whereby I created the following prop file:

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemDefinitionGroup>
    <Link>
       <DynamicBase>False</DynamicBase>
       <HighEntropyVA>False</HighEntropyVA>
    </Link>
  </ItemDefinitionGroup>
</Project>

and then added to the build using the command:
msbuild bitcoind/bitcoind.vcxproj /p:Platform=x64 /p:Configuration=Release /t:build /p:ForceImportBeforeCppTargets=profile.props

Source: Windows Questions C++

LEAVE A COMMENT