diff options
author | Rui Ueyama <ruiu@google.com> | 2013-12-16 06:41:06 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2013-12-16 06:41:06 +0000 |
commit | 0e05713d4709b8decf46001a10a4974a1cfa60b2 (patch) | |
tree | 8e498c1b8e56abf1b1420d8a11e3e3812425f037 | |
parent | fe1b3c09330705301bba4825b10260e4fe400d31 (diff) | |
download | bcm5719-llvm-0e05713d4709b8decf46001a10a4974a1cfa60b2.tar.gz bcm5719-llvm-0e05713d4709b8decf46001a10a4974a1cfa60b2.zip |
[PECOFF] Export ordinal must be in the range 1 through 65535.
llvm-svn: 197365
-rw-r--r-- | lld/lib/Driver/WinLinkDriver.cpp | 5 | ||||
-rw-r--r-- | lld/unittests/DriverTests/WinLinkDriverTest.cpp | 8 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lld/lib/Driver/WinLinkDriver.cpp b/lld/lib/Driver/WinLinkDriver.cpp index fbc6bfc01fc..79b006ddf85 100644 --- a/lld/lib/Driver/WinLinkDriver.cpp +++ b/lld/lib/Driver/WinLinkDriver.cpp @@ -328,6 +328,8 @@ bool parseExport(StringRef option, PECOFFLinkingContext::ExportDesc &ret) { 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 char *argv[], PECOFFLinkingContext &ctx, 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); diff --git a/lld/unittests/DriverTests/WinLinkDriverTest.cpp b/lld/unittests/DriverTests/WinLinkDriverTest.cpp index e31dffdddea..011ca414ff8 100644 --- a/lld/unittests/DriverTests/WinLinkDriverTest.cpp +++ b/lld/unittests/DriverTests/WinLinkDriverTest.cpp @@ -183,6 +183,14 @@ TEST_F(WinLinkParserTest, ExportWithOptions) { EXPECT_TRUE(exports[1].isData); } +TEST_F(WinLinkParserTest, ExportInvalid1) { + EXPECT_FALSE(parse("link.exe", "/export:foo,@0", "a.out", nullptr)); +} + +TEST_F(WinLinkParserTest, ExportInvalid2) { + EXPECT_FALSE(parse("link.exe", "/export:foo,@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()); |