[lld] r197365 - [PECOFF] Export ordinal must be in the range 1 through 65535.
Rui Ueyama
ruiu at google.com
Sun Dec 15 22:41:07 PST 2013
Author: ruiu
Date: Mon Dec 16 00:41:06 2013
New Revision: 197365
URL: http://llvm.org/viewvc/llvm-project?rev=197365&view=rev
Log:
[PECOFF] Export ordinal must be in the range 1 through 65535.
Modified:
lld/trunk/lib/Driver/WinLinkDriver.cpp
lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=197365&r1=197364&r2=197365&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Mon Dec 16 00:41:06 2013
@@ -328,6 +328,8 @@ bool parseExport(StringRef option, PECOF
int ordinal;
if (arg.substr(1).getAsInteger(0, ordinal))
return false;
+ if (ordinal <= 0 || 65535 < ordinal)
+ return false;
ret.ordinal = ordinal;
continue;
}
@@ -878,7 +880,8 @@ WinLinkDriver::parse(int argc, const cha
case OPT_export: {
PECOFFLinkingContext::ExportDesc desc;
if (!parseExport(inputArg->getValue(), desc)) {
- diagnostics << "Error: malformed /export option\n";
+ diagnostics << "Error: malformed /export option: "
+ << inputArg->getValue() << "\n";
return false;
}
ctx.addDllExport(desc);
Modified: lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=197365&r1=197364&r2=197365&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp Mon Dec 16 00:41:06 2013
@@ -183,6 +183,14 @@ TEST_F(WinLinkParserTest, ExportWithOpti
EXPECT_TRUE(exports[1].isData);
}
+TEST_F(WinLinkParserTest, ExportInvalid1) {
+ EXPECT_FALSE(parse("link.exe", "/export:foo, at 0", "a.out", nullptr));
+}
+
+TEST_F(WinLinkParserTest, ExportInvalid2) {
+ EXPECT_FALSE(parse("link.exe", "/export:foo, at 65536", "a.out", nullptr));
+}
+
TEST_F(WinLinkParserTest, MachineX86) {
EXPECT_TRUE(parse("link.exe", "/machine:x86", "a.obj", nullptr));
EXPECT_EQ(llvm::COFF::IMAGE_FILE_MACHINE_I386, _context.getMachineType());
More information about the llvm-commits
mailing list