'Returns the flags that need to be added to link commands, and the
manifest files.'

def GetLdflags(self, config, gyp_to_build_path, expand_special, manifest_base_name, output_name, is_executable, build_dir):

    config = self._TargetConfig(config)
    ldflags = []
    ld = self._GetWrapper(self, self.msvs_settings[config], 'VCLinkerTool', append=ldflags)
    self._GetDefFileAsLdflags(ldflags, gyp_to_build_path)
    ld('GenerateDebugInformation', map={'true': '/DEBUG'})
    ld('TargetMachine', map={'1': 'X86', '17': 'X64', '3': 'ARM'}, prefix='/MACHINE:')
    ldflags.extend(self._GetAdditionalLibraryDirectories('VCLinkerTool', config, gyp_to_build_path))
    ld('DelayLoadDLLs', prefix='/DELAYLOAD:')
    ld('TreatLinkerWarningAsErrors', prefix='/WX', map={'true': '', 'false': ':NO'})
    out = self.GetOutputName(config, expand_special)
    if out:
        ldflags.append(('/OUT:' + out))
    pdb = self.GetPDBName(config, expand_special, (output_name + '.pdb'))
    if pdb:
        ldflags.append(('/PDB:' + pdb))
    pgd = self.GetPGDName(config, expand_special)
    if pgd:
        ldflags.append(('/PGD:' + pgd))
    map_file = self.GetMapFileName(config, expand_special)
    ld('GenerateMapFile', map={'true': (('/MAP:' + map_file) if map_file else '/MAP')})
    ld('MapExports', map={'true': '/MAPINFO:EXPORTS'})
    ld('AdditionalOptions', prefix='')
    minimum_required_version = self._Setting(('VCLinkerTool', 'MinimumRequiredVersion'), config, default='')
    if minimum_required_version:
        minimum_required_version = (',' + minimum_required_version)
    ld('SubSystem', map={'1': ('CONSOLE%s' % minimum_required_version), '2': ('WINDOWS%s' % minimum_required_version)}, prefix='/SUBSYSTEM:')
    stack_reserve_size = self._Setting(('VCLinkerTool', 'StackReserveSize'), config, default='')
    if stack_reserve_size:
        stack_commit_size = self._Setting(('VCLinkerTool', 'StackCommitSize'), config, default='')
        if stack_commit_size:
            stack_commit_size = (',' + stack_commit_size)
        ldflags.append(('/STACK:%s%s' % (stack_reserve_size, stack_commit_size)))
    ld('TerminalServerAware', map={'1': ':NO', '2': ''}, prefix='/TSAWARE')
    ld('LinkIncremental', map={'1': ':NO', '2': ''}, prefix='/INCREMENTAL')
    ld('BaseAddress', prefix='/BASE:')
    ld('FixedBaseAddress', map={'1': ':NO', '2': ''}, prefix='/FIXED')
    ld('RandomizedBaseAddress', map={'1': ':NO', '2': ''}, prefix='/DYNAMICBASE')
    ld('DataExecutionPrevention', map={'1': ':NO', '2': ''}, prefix='/NXCOMPAT')
    ld('OptimizeReferences', map={'1': 'NOREF', '2': 'REF'}, prefix='/OPT:')
    ld('ForceSymbolReferences', prefix='/INCLUDE:')
    ld('EnableCOMDATFolding', map={'1': 'NOICF', '2': 'ICF'}, prefix='/OPT:')
    ld('LinkTimeCodeGeneration', map={'1': '', '2': ':PGINSTRUMENT', '3': ':PGOPTIMIZE', '4': ':PGUPDATE'}, prefix='/LTCG')
    ld('IgnoreDefaultLibraryNames', prefix='/NODEFAULTLIB:')
    ld('ResourceOnlyDLL', map={'true': '/NOENTRY'})
    ld('EntryPointSymbol', prefix='/ENTRY:')
    ld('Profile', map={'true': '/PROFILE'})
    ld('LargeAddressAware', map={'1': ':NO', '2': ''}, prefix='/LARGEADDRESSAWARE')
    ld('AdditionalDependencies', prefix='')
    if (self.GetArch(config) == 'x86'):
        safeseh_default = 'true'
    else:
        safeseh_default = None
    ld('ImageHasSafeExceptionHandlers', map={'false': ':NO', 'true': ''}, prefix='/SAFESEH', default=safeseh_default)
    base_flags = filter((lambda x: (('DYNAMICBASE' in x) or (x == '/FIXED'))), ldflags)
    if (not base_flags):
        ldflags.append('/DYNAMICBASE')
    if (not filter((lambda x: ('NXCOMPAT' in x)), ldflags)):
        ldflags.append('/NXCOMPAT')
    have_def_file = filter((lambda x: x.startswith('/DEF:')), ldflags)
    (manifest_flags, intermediate_manifest, manifest_files) = self._GetLdManifestFlags(config, manifest_base_name, gyp_to_build_path, (is_executable and (not have_def_file)), build_dir)
    ldflags.extend(manifest_flags)
    return (ldflags, intermediate_manifest, manifest_files)
