Commit 6a7307ea authored by Hans Wennborg's avatar Hans Wennborg
Browse files

Merging r308998 and r309002:

------------------------------------------------------------------------
r308998 | nico | 2017-07-25 11:08:03 -0700 (Tue, 25 Jul 2017) | 7 lines

lld: only write .manifest files if /manifest is passed, PR33925

Also emit an error if /manifestinput: is used without /manifest:embed.
Increases compatibility with link.exe

https://reviews.llvm.org/D35842

------------------------------------------------------------------------

------------------------------------------------------------------------
r309002 | nico | 2017-07-25 11:39:38 -0700 (Tue, 25 Jul 2017) | 6 lines

Attempt to fix lld tests on Windows after 308998.

The test used /manifestinput: without /manifest:embed, which isn't actually
supported.  Just remove this part of the test for now; if it's important to
check this the llvm-readobj part should be extended to check this.

------------------------------------------------------------------------

llvm-svn: 309128
parent 01884d24
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@ struct Configuration {
  std::map<StringRef, uint32_t> Section;

  // Options for manifest files.
  ManifestKind Manifest = SideBySide;
  ManifestKind Manifest = No;
  int ManifestID = 1;
  StringRef ManifestDependency;
  bool ManifestUAC = true;
+19 −7
Original line number Diff line number Diff line
@@ -899,18 +899,25 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
  for (auto *Arg : Args.filtered(OPT_section))
    parseSection(Arg->getValue());

  // Handle /manifest
  if (auto *Arg = Args.getLastArg(OPT_manifest_colon))
  // Handle /manifestdependency. This enables /manifest unless /manifest:no is
  // also passed.
  if (auto *Arg = Args.getLastArg(OPT_manifestdependency)) {
    Config->ManifestDependency = Arg->getValue();
    Config->Manifest = Configuration::SideBySide;
  }

  // Handle /manifest and /manifest:
  if (auto *Arg = Args.getLastArg(OPT_manifest, OPT_manifest_colon)) {
    if (Arg->getOption().getID() == OPT_manifest)
      Config->Manifest = Configuration::SideBySide;
    else
      parseManifest(Arg->getValue());
  }

  // Handle /manifestuac
  if (auto *Arg = Args.getLastArg(OPT_manifestuac))
    parseManifestUAC(Arg->getValue());

  // Handle /manifestdependency
  if (auto *Arg = Args.getLastArg(OPT_manifestdependency))
    Config->ManifestDependency = Arg->getValue();

  // Handle /manifestfile
  if (auto *Arg = Args.getLastArg(OPT_manifestfile))
    Config->ManifestFile = Arg->getValue();
@@ -919,6 +926,11 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
  for (auto *Arg : Args.filtered(OPT_manifestinput))
    Config->ManifestInput.push_back(Arg->getValue());

  if (!Config->ManifestInput.empty() &&
      Config->Manifest != Configuration::Embed) {
    fatal("/MANIFESTINPUT: requires /MANIFEST:EMBED");
  }

  // Handle miscellaneous boolean flags.
  if (Args.hasArg(OPT_allowisolation_no))
    Config->AllowIsolation = false;
+7 −2
Original line number Diff line number Diff line
# RUN: yaml2obj %p/Inputs/ret42.yaml > %t.obj

# RUN: rm -f %t.exe.manifest
# RUN: lld-link /out:%t.exe /entry:main %t.obj
# RUN: test ! -e %t.exe.manifest

# RUN: lld-link /manifest /out:%t.exe /entry:main %t.obj
# RUN: FileCheck -check-prefix=MANIFEST %s < %t.exe.manifest

MANIFEST: <?xml version="1.0" standalone="yes"?>
@@ -15,7 +19,7 @@ MANIFEST: </security>
MANIFEST:   </trustInfo>
MANIFEST: </assembly>

# RUN: lld-link /out:%t.exe /entry:main \
# RUN: lld-link /out:%t.exe /entry:main /manifest \
# RUN:   /manifestuac:"level='requireAdministrator' uiAccess='true'" %t.obj
# RUN: FileCheck -check-prefix=UAC %s < %t.exe.manifest

@@ -31,6 +35,7 @@ UAC: </security>
UAC:   </trustInfo>
UAC: </assembly>

# /manifestdependency implies /manifest. (/manifestuac doesn't.)
# RUN: lld-link /out:%t.exe /entry:main \
# RUN:   /manifestdependency:"foo='bar'" %t.obj
# RUN: FileCheck -check-prefix=DEPENDENCY %s < %t.exe.manifest
@@ -52,7 +57,7 @@ DEPENDENCY: </dependentAssembly>
DEPENDENCY:   </dependency>
DEPENDENCY: </assembly>

# RUN: lld-link /out:%t.exe /entry:main /manifestuac:no %t.obj
# RUN: lld-link /manifest /out:%t.exe /entry:main /manifestuac:no %t.obj
# RUN: FileCheck -check-prefix=NOUAC %s < %t.exe.manifest

NOUAC: <?xml version="1.0" standalone="yes"?>
+0 −9
Original line number Diff line number Diff line
# REQUIRES: win_mt

# RUN: yaml2obj %p/Inputs/ret42.yaml > %t.obj
# RUN: lld-link /out:%t.exe /entry:main \
# RUN:   /manifestuac:"level='requireAdministrator'" \
# RUN:   /manifestinput:%p/Inputs/manifestinput.test %t.obj
# RUN: FileCheck %s < %t.exe.manifest

CHECK: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
CHECK: <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"><dependency><dependentAssembly><assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity></dependentAssembly></dependency><trustInfo><security><requestedPrivileges><requestedExecutionLevel level="requireAdministrator" uiAccess="false"></requestedExecutionLevel></requestedPrivileges></security></trustInfo></assembly>

# RUN: yaml2obj %p/Inputs/ret42.yaml > %t.obj
# RUN: lld-link /out:%t.exe /entry:main \
# RUN:   /manifest:embed \