[PECOFF] Parse /dll command line option.

llvm-svn: 197123
This commit is contained in:
Rui Ueyama 2013-12-12 03:21:45 +00:00
parent 4cf5a16117
commit d3199fdd2e
3 changed files with 12 additions and 1 deletions

View File

@ -250,7 +250,7 @@ protected:
private:
// The start address for the program. The default value for the executable is
// 0x400000, but can be altered using -base command line option.
// 0x400000, but can be altered using /base command line option.
uint64_t _baseAddress;
uint64_t _stackReserve;

View File

@ -679,6 +679,14 @@ WinLinkDriver::parse(int argc, const char *argv[], PECOFFLinkingContext &ctx,
ctx.setBaseAddress(addr);
break;
case OPT_dll:
// Parse /dll command line option
ctx.setImageType(PECOFFLinkingContext::IMAGE_DLL);
// Default base address of a DLL is 0x10000000.
if (!parsedArgs->getLastArg(OPT_base))
ctx.setBaseAddress(0x10000000);
break;
case OPT_stack: {
// Parse /stack command line option
uint64_t reserve;

View File

@ -45,6 +45,7 @@ TEST_F(WinLinkParserTest, Basic) {
EXPECT_TRUE(_context.getInputSearchPaths().empty());
// Unspecified flags will have default values.
EXPECT_EQ(PECOFFLinkingContext::IMAGE_EXE, _context.getImageType());
EXPECT_EQ(6, _context.getMinOSVersion().majorVersion);
EXPECT_EQ(0, _context.getMinOSVersion().minorVersion);
EXPECT_EQ(0x400000U, _context.getBaseAddress());
@ -377,6 +378,8 @@ TEST_F(WinLinkParserTest, DisallowLib) {
TEST_F(WinLinkParserTest, NoEntry) {
EXPECT_TRUE(parse("link.exe", "/noentry", "/dll", "a.obj", nullptr));
EXPECT_EQ(PECOFFLinkingContext::IMAGE_DLL, _context.getImageType());
EXPECT_EQ(0x10000000U, _context.getBaseAddress());
EXPECT_EQ("", _context.entrySymbolName());
}