vs: Write checksums in PE binaries (DLLs and EXEs)

This is needed for detecting data corruption, and its absence (or
an incorrect value) is also used as a hint by anti-viruses that the
binary may be malware.

Flag is only supported by MSVC `link.exe`, not `lld-link.exe`

https://docs.microsoft.com/en-us/cpp/build/reference/release-set-the-checksum
pull/6435/head
Nirbheek Chauhan 4 years ago committed by Nirbheek Chauhan
parent 89b132f240
commit b293852d07
  1. 4
      mesonbuild/backend/vs2010backend.py
  2. 3
      mesonbuild/linkers.py

@ -1191,6 +1191,10 @@ class Vs2010Backend(backends.Backend):
targetmachine.text = 'MachineARM'
else:
raise MesonException('Unsupported Visual Studio target machine: ' + targetplatform)
# /nologo
ET.SubElement(link, 'SuppressStartupBanner').text = 'true'
# /release
ET.SubElement(link, 'SetChecksum').text = 'true'
meson_file_group = ET.SubElement(root, 'ItemGroup')
ET.SubElement(meson_file_group, 'None', Include=os.path.join(proj_to_src_dir, build_filename))

@ -845,6 +845,9 @@ class MSVCDynamicLinker(VisualStudioLikeLinkerMixin, DynamicLinker):
super().__init__(exelist or ['link.exe'], for_machine, 'link',
prefix, always_args, machine=machine, version=version, direct=direct)
def get_always_args(self) -> T.List[str]:
return self._apply_prefix(['/nologo', '/release']) + super().get_always_args()
class ClangClDynamicLinker(VisualStudioLikeLinkerMixin, DynamicLinker):

Loading…
Cancel
Save