[lld] r206633 - [PECOFF] Support /manifestuac:NO.
Rui Ueyama
ruiu at google.com
Fri Apr 18 12:43:08 PDT 2014
Author: ruiu
Date: Fri Apr 18 14:43:07 2014
New Revision: 206633
URL: http://llvm.org/viewvc/llvm-project?rev=206633&view=rev
Log:
[PECOFF] Support /manifestuac:NO.
If the value for /manifestuac is "NO", LLD will create a manifest XM
file but won't emit <trustinfo> element.
Modified:
lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
lld/trunk/lib/Driver/WinLinkDriver.cpp
lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
Modified: lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h?rev=206633&r1=206632&r2=206633&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h Fri Apr 18 14:43:07 2014
@@ -47,9 +47,9 @@ public:
_swapRunFromNet(false), _baseRelocationEnabled(true),
_terminalServerAware(true), _dynamicBaseEnabled(true),
_createManifest(true), _embedManifest(false), _manifestId(1),
- _manifestLevel("'asInvoker'"), _manifestUiAccess("'false'"),
- _isDll(false), _requireSEH(false), _noSEH(false),
- _dosStub(llvm::makeArrayRef(DEFAULT_DOS_STUB)) {
+ _manifestUAC(true), _manifestLevel("'asInvoker'"),
+ _manifestUiAccess("'false'"), _isDll(false), _requireSEH(false),
+ _noSEH(false), _dosStub(llvm::makeArrayRef(DEFAULT_DOS_STUB)) {
setDeadStripping(true);
}
@@ -183,6 +183,9 @@ public:
void setManifestId(int val) { _manifestId = val; }
int getManifestId() const { return _manifestId; }
+ void setManifestUAC(bool val) { _manifestUAC = val; }
+ bool getManifestUAC() const { return _manifestUAC; }
+
void setManifestLevel(std::string val) { _manifestLevel = std::move(val); }
const std::string &getManifestLevel() const { return _manifestLevel; }
@@ -311,6 +314,7 @@ private:
std::string _manifestOutputPath;
bool _embedManifest;
int _manifestId;
+ bool _manifestUAC;
std::string _manifestLevel;
std::string _manifestUiAccess;
std::string _manifestDependency;
Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=206633&r1=206632&r2=206633&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Fri Apr 18 14:43:07 2014
@@ -287,7 +287,7 @@ static bool parseManifest(StringRef opti
// The arguments will be embedded to the manifest XML file with no error check,
// so the values given via the command line must be valid as XML attributes.
// This may sound a bit odd, but that's how link.exe works, so we will follow.
-static bool parseManifestUac(StringRef option,
+static bool parseManifestUAC(StringRef option,
llvm::Optional<std::string> &level,
llvm::Optional<std::string> &uiAccess) {
for (;;) {
@@ -376,24 +376,26 @@ static std::string createManifestXml(PEC
// syntactically correct. This is intentional for link.exe compatibility.
out << "<?xml version=\"1.0\" standalone=\"yes\"?>\n"
"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\"\n"
- " manifestVersion=\"1.0\">\n"
- " <trustInfo>\n"
- " <security>\n"
- " <requestedPrivileges>\n"
- " <requestedExecutionLevel level=" << ctx.getManifestLevel()
- << " uiAccess=" << ctx.getManifestUiAccess()
- << "/>\n"
- " </requestedPrivileges>\n"
- " </security>\n"
- " </trustInfo>\n";
- const std::string &dependency = ctx.getManifestDependency();
- if (!dependency.empty()) {
- out << " <dependency>\n"
- " <dependentAssembly>\n"
- " <assemblyIdentity " << dependency
- << " />\n"
- " </dependentAssembly>\n"
- " </dependency>\n";
+ " manifestVersion=\"1.0\">\n";
+ if (ctx.getManifestUAC()) {
+ out << " <trustInfo>\n"
+ " <security>\n"
+ " <requestedPrivileges>\n"
+ " <requestedExecutionLevel level=" << ctx.getManifestLevel()
+ << " uiAccess=" << ctx.getManifestUiAccess()
+ << "/>\n"
+ " </requestedPrivileges>\n"
+ " </security>\n"
+ " </trustInfo>\n";
+ const std::string &dependency = ctx.getManifestDependency();
+ if (!dependency.empty()) {
+ out << " <dependency>\n"
+ " <dependentAssembly>\n"
+ " <assemblyIdentity " << dependency
+ << " />\n"
+ " </dependentAssembly>\n"
+ " </dependency>\n";
+ }
}
out << "</assembly>\n";
out.flush();
@@ -983,9 +985,13 @@ bool WinLinkDriver::parse(int argc, cons
case OPT_manifestuac: {
// Parse /manifestuac.
+ if (StringRef(inputArg->getValue()).equals_lower("no")) {
+ ctx.setManifestUAC(false);
+ break;
+ }
llvm::Optional<std::string> privilegeLevel;
llvm::Optional<std::string> uiAccess;
- if (!parseManifestUac(inputArg->getValue(), privilegeLevel, uiAccess)) {
+ if (!parseManifestUAC(inputArg->getValue(), privilegeLevel, uiAccess)) {
diag << "Unknown argument for /manifestuac: " << inputArg->getValue()
<< "\n";
return false;
Modified: lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=206633&r1=206632&r2=206633&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp Fri Apr 18 14:43:07 2014
@@ -68,6 +68,7 @@ TEST_F(WinLinkParserTest, Basic) {
EXPECT_EQ("", _context.getManifestDependency());
EXPECT_FALSE(_context.getEmbedManifest());
EXPECT_EQ(1, _context.getManifestId());
+ EXPECT_TRUE(_context.getManifestUAC());
EXPECT_EQ("'asInvoker'", _context.getManifestLevel());
EXPECT_EQ("'false'", _context.getManifestUiAccess());
EXPECT_TRUE(_context.deadStrip());
@@ -602,6 +603,11 @@ TEST_F(WinLinkParserTest, Manifest_Embed
EXPECT_EQ("'false'", _context.getManifestUiAccess());
}
+TEST_F(WinLinkParserTest, Manifestuac_no) {
+ EXPECT_TRUE(parse("link.exe", "/manifestuac:NO", "a.out", nullptr));
+ EXPECT_FALSE(_context.getManifestUAC());
+}
+
TEST_F(WinLinkParserTest, Manifestuac_Level) {
EXPECT_TRUE(parse("link.exe", "/manifestuac:level='requireAdministrator'",
"a.out", nullptr));
More information about the llvm-commits
mailing list