[lld] r227708 - [ELF] Implement semantic action for ENTRY linker script command.
Davide Italiano
davide at freebsd.org
Sat Jan 31 19:27:25 PST 2015
Author: davide
Date: Sat Jan 31 21:27:25 2015
New Revision: 227708
URL: http://llvm.org/viewvc/llvm-project?rev=227708&view=rev
Log:
[ELF] Implement semantic action for ENTRY linker script command.
Reviewed by: shankarke, ruiu
Modified:
lld/trunk/lib/Driver/GnuLdDriver.cpp
lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp
Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=227708&r1=227707&r2=227708&view=diff
==============================================================================
--- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/GnuLdDriver.cpp Sat Jan 31 21:27:25 2015
@@ -289,6 +289,8 @@ GnuLdDriver::evalLinkerScript(ELFLinking
return ec;
if (auto *searchDir = dyn_cast<script::SearchDir>(c))
ctx.addSearchPath(searchDir->getSearchPath());
+ if (auto *entry = dyn_cast<script::Entry>(c))
+ ctx.setEntrySymbolName(entry->getEntryName());
}
return std::error_code();
}
Modified: lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp?rev=227708&r1=227707&r2=227708&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp Sat Jan 31 21:27:25 2015
@@ -191,3 +191,16 @@ TEST_F(GnuLdParserTest, LinkerScriptSear
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<MemoryBuffer> 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);
+}
More information about the llvm-commits
mailing list