Index: lib/Driver/GnuLdDriver.cpp =================================================================== --- lib/Driver/GnuLdDriver.cpp +++ lib/Driver/GnuLdDriver.cpp @@ -289,6 +289,8 @@ return ec; if (auto *searchDir = dyn_cast(c)) ctx.addSearchPath(searchDir->getSearchPath()); + if (auto *entrySymbol = dyn_cast(c)) + ctx.setEntrySymbolName(entrySymbol->getEntryName()); } return std::error_code(); } Index: unittests/DriverTests/GnuLdDriverTest.cpp =================================================================== --- unittests/DriverTests/GnuLdDriverTest.cpp +++ unittests/DriverTests/GnuLdDriverTest.cpp @@ -191,3 +191,16 @@ EXPECT_EQ((size_t)2, searchPaths.size()); EXPECT_EQ("/foo/bar", searchPaths[1]); } + +TEST_F(GnuLdParserTest, LinkerScriptEntry) { + parse("ld", "a.o", nullptr); + std::unique_ptr mb = MemoryBuffer::getMemBuffer( + "ENTRY(blah)", "foo.so"); + std::string s; + raw_string_ostream out(s); + std::error_code ec = GnuLdDriver::evalLinkerScript( + *_context, std::move(mb), out); + EXPECT_FALSE(ec); + StringRef entrySymbol = _context->entrySymbolName(); + EXPECT_EQ("blah", entrySymbol); +}